Skip to content

Horizontally, Vertically & All with margin parameter - #111

Merged
lucdion merged 5 commits into
masterfrom
horizontallyMargin
Jan 12, 2018
Merged

lucdion merged 5 commits into
masterfrom
horizontallyMargin

Conversation

@OlivierPineau

Copy link
Copy Markdown
Contributor

No description provided.


@discardableResult
internal func top(_ value: CGFloat, _ context: Context) -> PinLayout {
setTop(value, context)

@lucdion lucdion Jan 11, 2018 •

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.

You don't need to add this method if you call setTop(value, context), setBottom(value, context) ... in func all(_ value: CGFloat),horizontally(...) and vertically(...)

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.

Ah, ok you can keep it that way, I use this pattern somewhere else 😊

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

:)

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.

But could you update the method func top(_ value: CGFloat) -> PinLayout in PinLayoutImpl.swift to:

@discardableResult
    func top(_ value: CGFloat) -> PinLayout {
        return top(value, { return "top(\(value))" })
    }


@discardableResult
internal func top(_ percent: Percent, _ context: Context) -> PinLayout {
guard let layoutSuperviewRect = layoutSuperviewRect(context) else { return self }

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.

Could you update the method func top(_ percent: Percent)-> PinLayout in PinLayoutImpl.swift to:

func top(_ percent: Percent) -> PinLayout {
        return top(percent,  { return "top(\(percent.description))" })
    }


@discardableResult
internal func bottom(_ percent: Percent, _ context: Context) -> PinLayout {
guard let layoutSuperviewRect = layoutSuperviewRect(context) else { return self }

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.

Could you update the method func bottom(_ percent: Percent) -> PinLayout in PinLayoutImpl.swift to:

func bottom(_ percent: Percent) -> PinLayout {
        return bottom(percent, { return "bottom(\(percent.description))" })
    }

Comment thread Sources/Impl/PinLayoutImpl.swift Outdated
@discardableResult
func all(_ value: CGFloat) -> PinLayout {
func context() -> String { return "all(\(value))" }
top(value, context)

@lucdion lucdion Jan 11, 2018 •

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.

Could you do as in all(), i.e. set a different context string for all internal calls (ex: { "all(\(value)) top coordinate" })

Comment thread Sources/Impl/PinLayoutImpl.swift Outdated
@discardableResult
func horizontally(_ value: CGFloat) -> PinLayout {
func context() -> String { return "horizontally(\(value))" }
left(value, context)

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.

Could you do as in all(), i.e. set a different context string for all internal calls (ex: { "horizontally(\(value)) left coordinate" })

Comment thread Sources/Impl/PinLayoutImpl.swift Outdated
@discardableResult
func horizontally(_ percent: Percent) -> PinLayout {
func context() -> String { return "horizontally(\(percent.description))" }
left(percent, context)

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.

Could you do as in all(), i.e. set a different context string for all internal calls (ex: { "horizontally(\(value)) left coordinate" })

Comment thread Sources/Impl/PinLayoutImpl.swift Outdated
@discardableResult
func vertically(_ value: CGFloat) -> PinLayout {
func context() -> String { return "vertically(\(value))" }
top(value, context)

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.

Could you do as in all(), i.e. set a different context string for all internal calls (ex: { "vertically(\(value)) top coordinate" })

Comment thread Sources/Impl/PinLayoutImpl.swift Outdated
@discardableResult
func vertically(_ percent: Percent) -> PinLayout {
func context() -> String { return "vertically(\(percent.description))" }
top(percent, context)

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.

Could you do as in all(), i.e. set a different context string for all internal calls (ex: { "vertically(\(value)) top coordinate" })

Comment thread Tests/PinEdgesSpec.swift Outdated
}
it("should warn") {
aView.pin.left(10).horizontally(20)
expect(Pin.lastWarningText).to(contain(["horizontally(20.0)", "won't be applied", "already been set to 10"]))

@lucdion lucdion Jan 11, 2018 •

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.

Once you have updated the method context, thanks to updating expectations, here it should contain left.

Comment thread Tests/PinEdgesSpec.swift
expect(Pin.lastWarningText).to(contain(["vertically() bottom coordinate", "won't be applied", "already been set to 20"]))
}
it("should warn") {
aView.pin.top(10).vertically(20)

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.

Once you have updated the method context, thanks to updating expectations, here it should contain top.

@lucdion lucdion 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.

Excellent, once you have fixed the little issues 👍

@codecov-io

codecov-io commented Jan 12, 2018 •

Copy link
Copy Markdown

Codecov Report

Merging #111 into master will decrease coverage by 0.02%.
The diff coverage is 88.65%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #111      +/-   ##
==========================================
- Coverage   90.94%   90.91%   -0.03%     
==========================================
  Files          34       34              
  Lines        6627     6718      +91     
==========================================
+ Hits         6027     6108      +81     
- Misses        600      610      +10
Impacted Files Coverage Δ
Sources/PinLayout.swift 100% <ø> (ø) ⬆️
Sources/ObjectiveC/PinLayoutObjCImpl.swift 3.2% <0%> (-0.05%) ⬇️
Tests/PinEdgesSpec.swift 100% <100%> (ø) ⬆️
Sources/Impl/PinLayoutImpl+Coordinates.swift 88.5% <100%> (+0.5%) ⬆️
Sources/Impl/PinLayoutImpl.swift 82.89% <79.16%> (-0.2%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e78fc48...f0f3fb7. Read the comment docs.

Comment thread Sources/Impl/PinLayoutImpl.swift Outdated

@discardableResult
func vertically(_ value: CGFloat) -> PinLayout {
top(value, { return "vertically(\(value)) top" })

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.

Just missing the "coordinate" word: "vertically((value)) top coordinate".
Also, for the bottom.

Comment thread Sources/Impl/PinLayoutImpl.swift Outdated

@discardableResult
func vertically(_ percent: Percent) -> PinLayout {
top(percent, { return "vertically(\(percent.description)) top" })

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.

Just missing the "coordinate" word: "vertically((value)) top coordinate".
Also, for the bottom.

@lucdion lucdion 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.

🎉

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.

3 participants