Skip to content

Commit 4180525

Browse files
committed
Fix context
1 parent a443817 commit 4180525

File tree

1 file changed

+54
-8
lines changed

1 file changed

+54
-8
lines changed

Sources/Impl/PinLayoutImpl.swift

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,11 @@ class PinLayoutImpl: PinLayout {
821821
@discardableResult
822822
func marginTop(_ percent: Percent) -> PinLayout {
823823
func context() -> String { return "marginTop(\(percent.description))" }
824+
return marginTop(percent, context)
825+
}
826+
827+
@discardableResult
828+
private func marginTop(_ percent: Percent, _ context: Context) -> Self {
824829
guard let layoutSuperviewRect = layoutSuperviewRect(context) else { return self }
825830
marginTop = percent.of(layoutSuperviewRect.height)
826831
return self
@@ -835,6 +840,11 @@ class PinLayoutImpl: PinLayout {
835840
@discardableResult
836841
func marginLeft(_ percent: Percent) -> PinLayout {
837842
func context() -> String { return "marginLeft(\(percent.description))" }
843+
return marginLeft(percent, context)
844+
}
845+
846+
@discardableResult
847+
private func marginLeft(_ percent: Percent, _ context: Context) -> Self {
838848
guard let layoutSuperviewRect = layoutSuperviewRect(context) else { return self }
839849
marginLeft = percent.of(layoutSuperviewRect.width)
840850
return self
@@ -849,6 +859,11 @@ class PinLayoutImpl: PinLayout {
849859
@discardableResult
850860
func marginBottom(_ percent: Percent) -> PinLayout {
851861
func context() -> String { return "marginBottom(\(percent.description))" }
862+
return marginBottom(percent, context)
863+
}
864+
865+
@discardableResult
866+
private func marginBottom(_ percent: Percent, _ context: Context) -> Self {
852867
guard let layoutSuperviewRect = layoutSuperviewRect(context) else { return self }
853868
marginBottom = percent.of(layoutSuperviewRect.height)
854869
return self
@@ -863,6 +878,11 @@ class PinLayoutImpl: PinLayout {
863878
@discardableResult
864879
func marginRight(_ percent: Percent) -> PinLayout {
865880
func context() -> String { return "marginRight(\(percent.description))" }
881+
return marginRight(percent, context)
882+
}
883+
884+
@discardableResult
885+
private func marginRight(_ percent: Percent, _ context: Context) -> Self {
866886
guard let layoutSuperviewRect = layoutSuperviewRect(context) else { return self }
867887
marginRight = percent.of(layoutSuperviewRect.width)
868888
return self
@@ -875,7 +895,8 @@ class PinLayoutImpl: PinLayout {
875895

876896
@discardableResult
877897
func marginStart(_ percent: Percent) -> PinLayout {
878-
return isLTR() ? marginLeft(percent) : marginRight(percent)
898+
func context() -> String { return "marginStart(\(percent.description))" }
899+
return isLTR() ? marginLeft(percent, context) : marginRight(percent, context)
879900
}
880901

881902
@discardableResult
@@ -885,7 +906,8 @@ class PinLayoutImpl: PinLayout {
885906

886907
@discardableResult
887908
func marginEnd(_ percent: Percent) -> PinLayout {
888-
return isLTR() ? marginRight(percent) : marginLeft(percent)
909+
func context() -> String { return "marginEnd(\(percent.description))" }
910+
return isLTR() ? marginRight(percent, context) : marginLeft(percent, context)
889911
}
890912

891913
@discardableResult
@@ -897,7 +919,13 @@ class PinLayoutImpl: PinLayout {
897919

898920
@discardableResult
899921
func marginHorizontal(_ percent: Percent) -> PinLayout {
900-
return marginLeft(percent).marginRight(percent)
922+
func context() -> String { return "marginHorizontal(\(percent.description))" }
923+
return marginHorizontal(percent, context)
924+
}
925+
926+
@discardableResult
927+
private func marginHorizontal(_ percent: Percent, _ context: Context) -> Self {
928+
return marginLeft(percent, context).marginRight(percent, context)
901929
}
902930

903931
@discardableResult
@@ -909,7 +937,13 @@ class PinLayoutImpl: PinLayout {
909937

910938
@discardableResult
911939
func marginVertical(_ percent: Percent) -> PinLayout {
912-
return marginTop(percent).marginBottom(percent)
940+
func context() -> String { return "marginVertical(\(percent.description))" }
941+
return marginVertical(percent, context)
942+
}
943+
944+
@discardableResult
945+
private func marginVertical(_ percent: Percent, _ context: Context) -> Self {
946+
return marginTop(percent, context).marginBottom(percent, context)
913947
}
914948

915949
@discardableResult
@@ -942,7 +976,11 @@ class PinLayoutImpl: PinLayout {
942976

943977
@discardableResult
944978
func margin(_ percent: Percent) -> PinLayout {
945-
return marginTop(percent).marginLeft(percent).marginBottom(percent).marginRight(percent)
979+
func context() -> String { return "margin(\(percent.description))" }
980+
return marginTop(percent, context)
981+
.marginLeft(percent, context)
982+
.marginBottom(percent, context)
983+
.marginRight(percent, context)
946984
}
947985

948986
@discardableResult
@@ -956,7 +994,13 @@ class PinLayoutImpl: PinLayout {
956994

957995
@discardableResult
958996
func margin(_ top: Percent, _ left: Percent, _ bottom: Percent, _ right: Percent) -> PinLayout {
959-
return marginTop(top).marginLeft(left).marginBottom(bottom).marginRight(right)
997+
func context() -> String {
998+
return "margin(top: \(top.description), left: \(left.description), bottom: \(bottom.description), right: \(right.description)"
999+
}
1000+
return marginTop(top, context)
1001+
.marginLeft(left, context)
1002+
.marginBottom(bottom, context)
1003+
.marginRight(right, context)
9601004
}
9611005

9621006
@discardableResult func margin(_ vertical: CGFloat, _ horizontal: CGFloat) -> PinLayout {
@@ -969,7 +1013,8 @@ class PinLayoutImpl: PinLayout {
9691013

9701014
@discardableResult
9711015
func margin(_ vertical: Percent, _ horizontal: Percent) -> PinLayout {
972-
return marginVertical(vertical).marginHorizontal(horizontal)
1016+
func context() -> String { return "margin(vertical: \(vertical.description), horizontal: \(horizontal.description)"}
1017+
return marginVertical(vertical, context).marginHorizontal(horizontal, context)
9731018
}
9741019

9751020
@discardableResult func margin(_ top: CGFloat, _ horizontal: CGFloat, _ bottom: CGFloat) -> PinLayout {
@@ -982,7 +1027,8 @@ class PinLayoutImpl: PinLayout {
9821027

9831028
@discardableResult
9841029
func margin(_ top: Percent, _ horizontal: Percent, _ bottom: Percent) -> PinLayout {
985-
return marginTop(top).marginHorizontal(horizontal).marginBottom(bottom)
1030+
func context() -> String { return "margin(top: \(top.description), horizontal: \(horizontal.description), bottom: \(bottom.description)"}
1031+
return marginTop(top, context).marginHorizontal(horizontal, context).marginBottom(bottom, context)
9861032
}
9871033

9881034
@discardableResult

0 commit comments

Comments
 (0)