Skip to content

Commit 47aa208

Browse files
author
Luc Dion
authored
Merge pull request #27 from mirego/percentages
Add methods that takes percentage parameters
2 parents b2255e4 + 2680397 commit 47aa208

File tree

11 files changed

+535
-370
lines changed

11 files changed

+535
-370
lines changed

Docs/Notes.txt

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99
TODO:
1010
===============================================
1111
- Nice introduction https://github.com/stevestreza/Relayout
12-
12+
13+
- Add a doc example using width(40%).height(100%)
14+
15+
- Add an image showing hCenter and vCenter (see http://doc.qt.io/qt-5/qtquick-positioning-anchors.html)
16+
17+
- Optimization: Use a bit mask to check rapidly which properties has been set. ex: if propertiesMask & (TOP | BOTTOM) { ... }
18+
1319
- Antoine Lamy: Suggestion pour ton système de layout (pt déjà le cas): Utiliser une interface entre l'engin de layout et
1420
UIKit afin de potentiellement être capable de le bridger vers d'autres entitées visuelles qu'une
1521
UIView (exemple: CALayer, NSView, ASDisplayNode, etc). L'engin n'a probablement à dealer qu'avec des
@@ -25,18 +31,30 @@
2531
pin.view.fill(), pin.fillHorizontally(), pin.fillVertically()
2632
pin.toSuperview()
2733

34+
* `allEdges()`
35+
Position
36+
* `verticalEdges()`
37+
Position
38+
* `horizontalEdges()`
39+
Position
40+
2841
- Percentages (see https://github.com/freshOS/Stevia/blob/master/Source/Stevia%2BPercentage.swift)
2942
pin.top(5%)
3043
pin.left(20%)
3144
pin.bottom(10%)
3245
pin.right(15%)
33-
pin.width(45%)
34-
pin.height(100%)
35-
pin.size(100%)
36-
pin.Height == 47 % button.Width
3746

3847
- Add parameter to sizeToFit indiquant si on doit caster ou pas le résultat
39-
- Add minHeight, maxHeight, ...
48+
49+
- max/max height/width
50+
- minWidth(CGFloat)
51+
- minWidth(Percent)
52+
- maxWidth(CGFloat)
53+
- maxWidth(Percent)
54+
- minHeight(CGFloat)
55+
- minHeight(Percent)
56+
- maxHeight(CGFloat)
57+
- maxHeight(Percent)
4058

4159
- Add size(_ width: CGFloat, _ height: CGFloat)
4260
- Add size(widthAndHeight: CGFloat)

PinLayout.xcodeproj/project.pbxproj

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
249EFE891E64FB4C00165E39 /* PinLayoutTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 249EFE881E64FB4C00165E39 /* PinLayoutTests.swift */; };
2424
249EFE8B1E64FB4C00165E39 /* PinLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = 249EFE7D1E64FB4C00165E39 /* PinLayout.h */; settings = {ATTRIBUTES = (Public, ); }; };
2525
DF11A3711E833F03008B33E5 /* TypesImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF11A3701E833F03008B33E5 /* TypesImpl.swift */; };
26-
DF11A3781E834B32008B33E5 /* UIView+PinLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF11A3771E834B32008B33E5 /* UIView+PinLayout.swift */; };
2726
DF11A37A1E834B3F008B33E5 /* Coordinates.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF11A3791E834B3F008B33E5 /* Coordinates.swift */; };
2827
DF7A36BD1E918301000F9856 /* PinEdgesSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF7A36BC1E918301000F9856 /* PinEdgesSpec.swift */; };
2928
DFC97CA51E8A8EB3001545D5 /* PinLayoutImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFC97CA41E8A8EB3001545D5 /* PinLayoutImpl.swift */; };
@@ -72,7 +71,6 @@
7271
249EFE881E64FB4C00165E39 /* PinLayoutTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PinLayoutTests.swift; sourceTree = "<group>"; };
7372
249EFE8A1E64FB4C00165E39 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7473
DF11A3701E833F03008B33E5 /* TypesImpl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TypesImpl.swift; sourceTree = "<group>"; };
75-
DF11A3771E834B32008B33E5 /* UIView+PinLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+PinLayout.swift"; sourceTree = "<group>"; };
7674
DF11A3791E834B3F008B33E5 /* Coordinates.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Coordinates.swift; sourceTree = "<group>"; };
7775
DF7A36BC1E918301000F9856 /* PinEdgesSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PinEdgesSpec.swift; sourceTree = "<group>"; };
7876
DFC97CA41E8A8EB3001545D5 /* PinLayoutImpl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PinLayoutImpl.swift; sourceTree = "<group>"; };
@@ -134,7 +132,6 @@
134132
children = (
135133
DFC97CA61E8A8F2C001545D5 /* PinLayout.swift */,
136134
DFA06B031E8B38B300B6D5E7 /* Impl */,
137-
DF11A3751E834194008B33E5 /* Extensions */,
138135
DF11A3761E8341A2008B33E5 /* Helpers */,
139136
);
140137
path = PinLayout;
@@ -167,14 +164,6 @@
167164
path = "Supporting Files";
168165
sourceTree = "<group>";
169166
};
170-
DF11A3751E834194008B33E5 /* Extensions */ = {
171-
isa = PBXGroup;
172-
children = (
173-
DF11A3771E834B32008B33E5 /* UIView+PinLayout.swift */,
174-
);
175-
path = Extensions;
176-
sourceTree = "<group>";
177-
};
178167
DF11A3761E8341A2008B33E5 /* Helpers */ = {
179168
isa = PBXGroup;
180169
children = (
@@ -325,7 +314,6 @@
325314
buildActionMask = 2147483647;
326315
files = (
327316
DF11A3711E833F03008B33E5 /* TypesImpl.swift in Sources */,
328-
DF11A3781E834B32008B33E5 /* UIView+PinLayout.swift in Sources */,
329317
DF11A37A1E834B3F008B33E5 /* Coordinates.swift in Sources */,
330318
DFC97CA71E8A8F2C001545D5 /* PinLayout.swift in Sources */,
331319
DFC97CA51E8A8EB3001545D5 /* PinLayoutImpl.swift in Sources */,

PinLayout/Extensions/UIView+PinLayout.swift

Lines changed: 0 additions & 152 deletions
This file was deleted.

PinLayout/Helpers/Coordinates.swift

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,6 @@
2828
import UIKit
2929

3030
class Coordinates {
31-
static func top(_ view: UIView) -> CGFloat {
32-
return view.frame.minY
33-
}
34-
35-
static func left(_ view: UIView) -> CGFloat {
36-
return view.frame.minX
37-
}
38-
39-
static func bottom(_ view: UIView) -> CGFloat {
40-
return view.frame.maxY
41-
}
42-
43-
static func right(_ view: UIView) -> CGFloat {
44-
return view.frame.maxX
45-
}
46-
4731
static func hCenter(_ view: UIView) -> CGFloat {
4832
return view.frame.minX + (view.frame.width / 2)
4933
}
@@ -52,17 +36,6 @@ class Coordinates {
5236
return view.frame.minY + (view.frame.height / 2)
5337
}
5438

55-
// static func size(_ view: UIView) -> CGSize {
56-
// return view.frame.size
57-
// }
58-
// static func width(_ view: UIView) -> CGFloat {
59-
// return view.frame.width
60-
// }
61-
//
62-
// static func height(_ view: UIView) -> CGFloat {
63-
// return view.frame.height
64-
// }
65-
6639
static func topLeft(_ view: UIView) -> CGPoint {
6740
return CGPoint(x: view.frame.minX, y: view.frame.minY)
6841
}
@@ -115,8 +88,4 @@ class Coordinates {
11588
static func ceilFloatToDisplayScale(_ pointValue: CGFloat) -> CGFloat {
11689
return CGFloat(ceilf(Float(pointValue * displayScale))) / displayScale
11790
}
118-
119-
static func overwriteDisplayScaleForUnitTest(scale: CGFloat) {
120-
displayScale = scale
121-
}
12291
}

0 commit comments

Comments
 (0)