Skip to content

Commit 44697d4

Browse files
author
Ruslan Dzhafarov
committed
minor fixes
1 parent 46e93fa commit 44697d4

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

Sources/Extensions/CALayer+PinLayout.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ extension CALayer: Layoutable {
3030
return sublayers ?? []
3131
}
3232

33-
public var isVisible: Bool {
34-
!isHidden && opacity > 0
33+
public var isConsideredVisibleForViewFilters: Bool {
34+
return !isHidden && opacity > 0
3535
}
3636

3737
public var pin: PinLayout<CALayer> {

Sources/Extensions/NSView+PinLayout.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ extension NSView: Layoutable {
3333
return PinLayout(view: self, keepTransform: false)
3434
}
3535

36-
public var isVisible: Bool {
37-
!isHidden && alphaValue > 0
36+
public var isConsideredVisibleForViewFilters: Bool {
37+
return !isHidden && alphaValue > 0
3838
}
3939

4040
@objc public var pinObjc: PinLayoutObjC {

Sources/Extensions/UIView+PinLayout.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ extension UIView: Layoutable, SizeCalculable {
3737
return PinLayoutObjCImpl(view: self, keepTransform: true)
3838
}
3939

40-
public var isVisible: Bool {
41-
!isHidden && alpha > 0
40+
public var isConsideredVisibleForViewFilters: Bool {
41+
return !isHidden && alpha > 0
4242
}
4343

4444
public func getRect(keepTransform: Bool) -> CGRect {

Sources/Layoutable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public protocol Layoutable: AnyObject, Equatable, CustomDebugStringConvertible {
2929
var superview: PinView? { get }
3030
var subviews: [PinView] { get }
3131

32-
var isVisible: Bool { get }
32+
var isConsideredVisibleForViewFilters: Bool { get }
3333

3434
func getRect(keepTransform: Bool) -> CGRect
3535
func setRect(_ rect: CGRect, keepTransform: Bool)

Sources/PinLayout+WrapContent.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ extension PinLayout {
3131
- viewFilter: Specify whether to include all views or only visible ones.
3232
*/
3333
@discardableResult
34-
public func wrapContent(viewFilter: ViewFilter = .none) -> PinLayout {
34+
public func wrapContent(viewFilter: ViewFilter = .all) -> PinLayout {
3535
return wrapContent(.all, padding: PEdgeInsets(top: 0, left: 0, bottom: 0, right: 0), viewFilter: viewFilter, { return "wrapContent()" })
3636
}
3737

@@ -43,7 +43,7 @@ extension PinLayout {
4343
- viewFilter: Specify whether to include all views or only visible ones.
4444
*/
4545
@discardableResult
46-
public func wrapContent(padding: CGFloat, viewFilter: ViewFilter = .none) -> PinLayout {
46+
public func wrapContent(padding: CGFloat, viewFilter: ViewFilter = .all) -> PinLayout {
4747
return wrapContent(.all, padding: PEdgeInsets(top: padding, left: padding, bottom: padding, right: padding), viewFilter: viewFilter, { return "wrapContent(padding: \(padding)" })
4848
}
4949

@@ -58,7 +58,7 @@ extension PinLayout {
5858
- viewFilter: Specify whether to include all views or only visible ones.
5959
*/
6060
@discardableResult
61-
public func wrapContent(padding: PEdgeInsets, viewFilter: ViewFilter = .none) -> PinLayout {
61+
public func wrapContent(padding: PEdgeInsets, viewFilter: ViewFilter = .all) -> PinLayout {
6262
return wrapContent(.all, padding: padding, viewFilter: viewFilter, { return "wrapContent(padding: \(insetsDescription(padding))" })
6363
}
6464

@@ -72,7 +72,7 @@ extension PinLayout {
7272
- viewFilter: Specify whether to include all views or only visible ones.
7373
*/
7474
@discardableResult
75-
public func wrapContent(_ type: WrapType, viewFilter: ViewFilter = .none) -> PinLayout {
75+
public func wrapContent(_ type: WrapType, viewFilter: ViewFilter = .all) -> PinLayout {
7676
return wrapContent(type, padding: PEdgeInsets(top: 0, left: 0, bottom: 0, right: 0), viewFilter: viewFilter, { return "wrapContent(\(type.description)" })
7777
}
7878

@@ -88,7 +88,7 @@ extension PinLayout {
8888
- viewFilter: Specify whether to include all views or only visible ones.
8989
*/
9090
@discardableResult
91-
public func wrapContent(_ type: WrapType, padding: CGFloat, viewFilter: ViewFilter = .none) -> PinLayout {
91+
public func wrapContent(_ type: WrapType, padding: CGFloat, viewFilter: ViewFilter = .all) -> PinLayout {
9292
return wrapContent(type, padding: PEdgeInsets(top: padding, left: padding, bottom: padding, right: padding), viewFilter: viewFilter, { return "wrapContent(\(type.description), padding: \(padding)" })
9393
}
9494

@@ -104,16 +104,16 @@ extension PinLayout {
104104
- viewFilter: Specify whether to include all views or only visible ones.
105105
*/
106106
@discardableResult
107-
public func wrapContent(_ type: WrapType, padding: PEdgeInsets, viewFilter: ViewFilter = .none) -> PinLayout {
107+
public func wrapContent(_ type: WrapType, padding: PEdgeInsets, viewFilter: ViewFilter = .all) -> PinLayout {
108108
return wrapContent(type, padding: padding, viewFilter: viewFilter, { return "wrapContent(\(type.description), padding: \(insetsDescription(padding))" })
109109
}
110110

111111
private func wrapContent(_ type: WrapType, padding: PEdgeInsets, viewFilter: ViewFilter, _ context: Context) -> PinLayout {
112112
let subviews: [PinView.PinView]
113113
switch viewFilter {
114114
case .visibleOnly:
115-
subviews = view.subviews.filter { $0.isVisible }
116-
case .none:
115+
subviews = view.subviews.filter { $0.isConsideredVisibleForViewFilters }
116+
case .all:
117117
subviews = view.subviews
118118
}
119119

Sources/Types.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ public enum FitType {
195195
}
196196

197197
@objc public enum ViewFilter: Int {
198-
/// No filter, use all views
199-
case none
198+
/// Consider all views
199+
case all
200200
/// Consider only visible views (isHidden is false and alpha is > 0)
201201
case visibleOnly
202202
}

0 commit comments

Comments
 (0)