Skip to content

Commit 9cbed67

Browse files
committed
remove some invalid code
1 parent ba6e09c commit 9cbed67

5 files changed

Lines changed: 48 additions & 65 deletions

File tree

Sources/StackKit/HStackView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ open class HStackView: UIView {
8080

8181
private func tryResizeStackView() {
8282
subviews.forEach { fitSize in
83-
fitSize._fitSize(with: fitSize.stackKitFitType)
83+
fitSize._fitSize(with: fitSize._stackKit_fitType)
8484
}
8585
}
8686

Sources/StackKit/UIView+StackKit/UIView+FitSize.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import UIKit
22

3-
var _FitTypeKey = "_FitTypeKey"
3+
var _StackKit_FitTypeKey = "_StackKit_FitTypeKey"
44

55
public enum FitType {
66
case content
@@ -22,26 +22,26 @@ public enum FitType {
2222
}
2323

2424
protocol FitSize {
25-
var stackKitFitType: FitType { get set }
25+
var _stackKit_fitType: FitType { get set }
2626
func _fitSize(with fitType: FitType)
2727
}
2828

2929
extension UIView: FitSize {
3030

31-
var stackKitFitType: FitType {
31+
var _stackKit_fitType: FitType {
3232
get {
33-
guard let fitType = objc_getAssociatedObject(self, &_FitTypeKey) as? FitType else {
33+
guard let fitType = objc_getAssociatedObject(self, &_StackKit_FitTypeKey) as? FitType else {
3434
return .content
3535
}
3636
return fitType
3737
}
3838
set {
39-
objc_setAssociatedObject(self, &_FitTypeKey, newValue, .OBJC_ASSOCIATION_COPY_NONATOMIC)
39+
objc_setAssociatedObject(self, &_StackKit_FitTypeKey, newValue, .OBJC_ASSOCIATION_COPY_NONATOMIC)
4040
}
4141
}
4242

4343
func fitSize(with fitType: FitType) -> Self {
44-
self.stackKitFitType = fitType
44+
self._stackKit_fitType = fitType
4545
return self
4646
}
4747

@@ -118,10 +118,10 @@ extension UIView: FitSize {
118118
}
119119

120120
private func _fixedSize(_ size: inout Size) {
121-
if let w = _width {
121+
if let w = _stackKit_width {
122122
size.width = w
123123
}
124-
if let h = _height {
124+
if let h = _stackKit_height {
125125
size.height = h
126126
}
127127
}
@@ -140,10 +140,10 @@ extension UIView {
140140

141141
func resolveSize() -> Size {
142142
var size = Size()
143-
if let _width = _width {
143+
if let _width = _stackKit_width {
144144
size.width = _width
145145
}
146-
if let _height = _height {
146+
if let _height = _stackKit_height {
147147
size.height = _height
148148
}
149149
return size
@@ -153,12 +153,12 @@ extension UIView {
153153
var result = width
154154

155155
// Handle minWidth
156-
if let minWidth = _minWidth, minWidth > (result ?? 0) {
156+
if let minWidth = _stackKit_minWidth, minWidth > (result ?? 0) {
157157
result = minWidth
158158
}
159159

160160
// Handle maxWidth
161-
if let maxWidth = _maxWidth, maxWidth < (result ?? CGFloat.greatestFiniteMagnitude) {
161+
if let maxWidth = _stackKit_maxWidth, maxWidth < (result ?? CGFloat.greatestFiniteMagnitude) {
162162
result = maxWidth
163163
}
164164
return result
@@ -168,12 +168,12 @@ extension UIView {
168168
var result = height
169169

170170
// Handle minWidth
171-
if let minWidth = _minHeight, minWidth > (result ?? 0) {
171+
if let minWidth = _stackKit_minHeight, minWidth > (result ?? 0) {
172172
result = minWidth
173173
}
174174

175175
// Handle maxWidth
176-
if let maxWidth = _maxHeight, maxWidth < (result ?? CGFloat.greatestFiniteMagnitude) {
176+
if let maxWidth = _stackKit_maxHeight, maxWidth < (result ?? CGFloat.greatestFiniteMagnitude) {
177177
result = maxWidth
178178
}
179179

Sources/StackKit/UIView+StackKit/UIView+StackKitCompatibleProvider.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,60 +15,60 @@ extension StackKitCompatible where Base: UIView {
1515

1616
@discardableResult
1717
public func width(_ value: CGFloat?) -> Self {
18-
view._width = value
18+
view._stackKit_width = value
1919
return self
2020
}
2121
@discardableResult
2222
public func height(_ value: CGFloat?) -> Self {
23-
view._height = value
23+
view._stackKit_height = value
2424
return self
2525
}
2626

2727
@discardableResult
2828
public func maxWidth(_ value: CGFloat?) -> Self {
29-
view._maxWidth = value
29+
view._stackKit_maxWidth = value
3030
return self
3131
}
3232
@discardableResult
3333
public func maxHeight(_ value: CGFloat?) -> Self {
34-
view._maxHeight = value
34+
view._stackKit_maxHeight = value
3535
return self
3636
}
3737
@discardableResult
3838
public func minWidth(_ value: CGFloat?) -> Self {
39-
view._minWidth = value
39+
view._stackKit_minWidth = value
4040
return self
4141
}
4242
@discardableResult
4343
public func minHeight(_ value: CGFloat?) -> Self {
44-
view._minHeight = value
44+
view._stackKit_minHeight = value
4545
return self
4646
}
4747

4848
@discardableResult
4949
public func size(_ length: CGFloat) -> Self {
50-
view._width = length
51-
view._height = length
50+
view._stackKit_width = length
51+
view._stackKit_height = length
5252
return self
5353
}
5454

5555
@discardableResult
5656
public func size(_ width: CGFloat, _ height: CGFloat) -> Self {
57-
view._width = width
58-
view._height = height
57+
view._stackKit_width = width
58+
view._stackKit_height = height
5959
return self
6060
}
6161

6262
@discardableResult
6363
public func size(_ size: CGSize) -> Self {
64-
view._width = size.width
65-
view._height = size.height
64+
view._stackKit_width = size.width
65+
view._stackKit_height = size.height
6666
return self
6767
}
6868

6969
@discardableResult
7070
public func sizeToFit(_ fitType: FitType = .content) -> Self {
71-
view.stackKitFitType = fitType
71+
view._stackKit_fitType = fitType
7272
return self
7373
}
7474

Sources/StackKit/UIView+StackKit/_UIView_StackKitProvider.swift

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,81 +12,64 @@ struct _UIView_StackKitKeys {
1212
}
1313

1414
protocol _UIView_StackKitProvider {
15-
var _width: CGFloat? { get set }
16-
var _height: CGFloat? { get set }
15+
var _stackKit_width: CGFloat? { get set }
16+
var _stackKit_height: CGFloat? { get set }
1717

18-
var _minWidth: CGFloat? { get set }
19-
var _maxWidth: CGFloat? { get set }
18+
var _stackKit_minWidth: CGFloat? { get set }
19+
var _stackKit_maxWidth: CGFloat? { get set }
2020

21-
var _minHeight: CGFloat? { get set }
22-
var _maxHeight: CGFloat? { get set }
21+
var _stackKit_minHeight: CGFloat? { get set }
22+
var _stackKit_maxHeight: CGFloat? { get set }
2323
}
2424

2525
extension UIView: _UIView_StackKitProvider {
26-
var _width: CGFloat? {
26+
27+
var _stackKit_width: CGFloat? {
2728
get {
28-
guard let value = Runtime.getCGFloatProperty(self, key: &_UIView_StackKitKeys.widthKey) else {
29-
return nil
30-
}
31-
return value
29+
Runtime.getCGFloatProperty(self, key: &_UIView_StackKitKeys.widthKey)
3230
}
3331
set {
3432
Runtime.setCGFloatProperty(self, key: &_UIView_StackKitKeys.widthKey, newValue)
3533
}
3634
}
37-
var _height: CGFloat? {
35+
var _stackKit_height: CGFloat? {
3836
get {
39-
guard let value = Runtime.getCGFloatProperty(self, key: &_UIView_StackKitKeys.heightKey) else {
40-
return nil
41-
}
42-
return value
37+
Runtime.getCGFloatProperty(self, key: &_UIView_StackKitKeys.heightKey)
4338
}
4439
set {
4540
Runtime.setCGFloatProperty(self, key: &_UIView_StackKitKeys.heightKey, newValue)
4641
}
4742
}
48-
var _minWidth: CGFloat? {
43+
var _stackKit_minWidth: CGFloat? {
4944
get {
50-
guard let value = Runtime.getCGFloatProperty(self, key: &_UIView_StackKitKeys.minWidthKey) else {
51-
return nil
52-
}
53-
return value
45+
Runtime.getCGFloatProperty(self, key: &_UIView_StackKitKeys.minWidthKey)
5446
}
5547
set {
5648
Runtime.setCGFloatProperty(self, key: &_UIView_StackKitKeys.minWidthKey, newValue)
5749
}
5850
}
5951

60-
var _maxWidth: CGFloat? {
52+
var _stackKit_maxWidth: CGFloat? {
6153
get {
62-
guard let value = Runtime.getCGFloatProperty(self, key: &_UIView_StackKitKeys.maxWidthKey) else {
63-
return nil
64-
}
65-
return value
54+
Runtime.getCGFloatProperty(self, key: &_UIView_StackKitKeys.maxWidthKey)
6655
}
6756
set {
6857
Runtime.setCGFloatProperty(self, key: &_UIView_StackKitKeys.maxWidthKey, newValue)
6958
}
7059
}
7160

72-
var _minHeight: CGFloat? {
61+
var _stackKit_minHeight: CGFloat? {
7362
get {
74-
guard let value = Runtime.getCGFloatProperty(self, key: &_UIView_StackKitKeys.minHeightKey) else {
75-
return nil
76-
}
77-
return value
63+
Runtime.getCGFloatProperty(self, key: &_UIView_StackKitKeys.minHeightKey)
7864
}
7965
set {
8066
Runtime.setCGFloatProperty(self, key: &_UIView_StackKitKeys.minHeightKey, newValue)
8167
}
8268
}
8369

84-
var _maxHeight: CGFloat? {
70+
var _stackKit_maxHeight: CGFloat? {
8571
get {
86-
guard let value = Runtime.getCGFloatProperty(self, key: &_UIView_StackKitKeys.maxHeightKey) else {
87-
return nil
88-
}
89-
return value
72+
Runtime.getCGFloatProperty(self, key: &_UIView_StackKitKeys.maxHeightKey)
9073
}
9174
set {
9275
Runtime.setCGFloatProperty(self, key: &_UIView_StackKitKeys.maxHeightKey, newValue)

Sources/StackKit/VStackView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ open class VStackView: UIView {
8080

8181
private func tryResizeStackView() {
8282
subviews.forEach { fitSize in
83-
fitSize._fitSize(with: fitSize.stackKitFitType)
83+
fitSize._fitSize(with: fitSize._stackKit_fitType)
8484
}
8585
}
8686

0 commit comments

Comments
 (0)