Skip to content

Commit 854fdd2

Browse files
author
Luc Dion
authored
Merge pull request #8 from lucdion/rename_addContainer_to_addItem
Renamed the method `addContainer()` to `addItem()`.
2 parents 2960fe6 + ac7a653 commit 854fdd2

File tree

8 files changed

+43
-45
lines changed

8 files changed

+43
-45
lines changed

CHANGELOG.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,22 @@
77

88
# Change Log
99

10+
## [1.1.0](https://github.com/lucdion/FlexLayout/releases/tag/1.1.0)
11+
Released on 2017-08-23
12+
13+
* Add missing markDirty() method
14+
* :warning: BREAKING CHANGE: Renamed the method `addContainer()` to `addItem(). It is clearer that the added view is in fact a flex item, and not just a flex container.
15+
* Added by [Luc Dion](https://github.com/lucdion) in Pull Request [#8](https://github.com/lucdion/FlexLayout/pull/8 )
16+
* Add an implementation of the Ray Wenderlich Yoga Tutorial
17+
* Added by [Luc Dion](https://github.com/lucdion) in Pull Request [#7](https://github.com/lucdion/FlexLayout/pull/7)
18+
19+
## [1.0.0](https://github.com/lucdion/FlexLayout/releases/tag/1.0.0)
20+
Released on 2017-08-20
21+
22+
* Initial official release.
23+
* Add unit tests
24+
1025
## [0.1.1](https://github.com/lucdion/FlexLayout/releases/tag/0.1.1)
1126
Released on 2017-08-02
1227

13-
* Initial official release.
28+
* Initial beta release.

Example/FlexLayoutSample/UI/Examples/Intro/IntroView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ class IntroView: BaseView {
3636
bottomLabel.numberOfLines = 0
3737

3838
rootFlexContainer.flex.direction(.column).padding(12).define { (flex) in
39-
flex.addContainer().direction(.row).define { (flex) in
39+
flex.addItem().direction(.row).define { (flex) in
4040
flex.addItem(imageView).width(100).aspectRatio(of: imageView)
4141

42-
flex.addContainer().direction(.column).paddingLeft(12).grow(1).shrink(1).define { (flex) in
42+
flex.addItem().direction(.column).paddingLeft(12).grow(1).shrink(1).define { (flex) in
4343
flex.addItem(segmentedControl).marginBottom(12).grow(1)
4444
flex.addItem(label)
4545
}
4646
}
4747

48-
flex.addContainer().height(1).marginTop(12).backgroundColor(.lightGray)
48+
flex.addItem().height(1).marginTop(12).backgroundColor(.lightGray)
4949
flex.addItem(bottomLabel).marginTop(12)
5050
}
5151

Example/FlexLayoutSample/UI/Examples/YogaExampleA/YogaExampleAView.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,8 @@ class YogaExampleAView: BaseView {
2424

2525
// Yoga's C Example
2626
rootFlexContainer.flex.direction(.row).padding(20).define { (flex) in
27-
flex.addContainer().width(80).marginEnd(20).define({ (flex) in
28-
flex.view.backgroundColor = .flexLayoutColor
29-
})
30-
31-
flex.addContainer().height(25).alignSelf(.center).grow(1).define({ (flex) in
32-
flex.view.backgroundColor = .black
33-
})
27+
flex.addItem().width(80).marginEnd(20).backgroundColor(.flexLayoutColor)
28+
flex.addItem().height(25).alignSelf(.center).grow(1).backgroundColor(.black)
3429
}
3530
addSubview(rootFlexContainer)
3631
}

Example/FlexLayoutSample/UI/Examples/YogaExampleE/YogaExampleEView.swift

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,9 @@ class YogaExampleEView: BaseView {
2929
rootFlexContainer.flex.define { (flex) in
3030
flex.addItem(imageView).grow(1)
3131

32-
flex.addContainer().direction(.row).padding(20).alignItems(.center).define({ (flex) in
33-
flex.addContainer().size(50).define({ (flex) in
34-
flex.view.backgroundColor = .flexLayoutColor
35-
})
36-
37-
flex.addContainer().height(25).marginStart(20).grow(1).define({ (flex) in
38-
flex.view.backgroundColor = .black
39-
})
32+
flex.addItem().direction(.row).padding(20).alignItems(.center).define({ (flex) in
33+
flex.addItem().size(50).backgroundColor(.flexLayoutColor)
34+
flex.addItem().height(25).marginStart(20).grow(1).backgroundColor(.black)
4035
})
4136
}
4237
addSubview(rootFlexContainer)

FlexLayout.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Pod::Spec.new do |s|
33
s.name = "FlexLayout"
4-
s.version = "1.0.0"
4+
s.version = "1.1.0"
55
s.summary = "FlexLayout"
66

77
s.homepage = "https://github.com/lucdion/FlexLayout.git"

README.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,17 @@ init() {
8888
// Column container
8989
rootFlexContainer.flex.direction(.column).padding(12).define { (flex) in
9090
// Row container
91-
flex.addContainer().direction(.row).define { (flex) in
91+
flex.addItem().direction(.row).define { (flex) in
9292
flex.addItem(imageView).width(100).aspectRatio(of: imageView)
9393

9494
// Column container
95-
flex.addContainer().direction(.column).paddingLeft(12).grow(1).define { (flex) in
95+
flex.addItem().direction(.column).paddingLeft(12).grow(1).define { (flex) in
9696
flex.addItem(segmentedControl).marginBottom(12).grow(1)
9797
flex.addItem(label)
9898
}
9999
}
100100

101-
flex.addContainer().height(1).marginTop(12).backgroundColor(.lightGray)
101+
flex.addItem().height(1).marginTop(12).backgroundColor(.lightGray)
102102
flex.addItem(bottomLabel).marginTop(12)
103103
}
104104
}
@@ -256,7 +256,6 @@ These results also means that **FlexLayout and PinLayout are by far faster than
256256

257257
* **FlexLayout additions**:
258258
* addItem()
259-
* addContainer()
260259
* define()
261260
* layout()
262261
* isIncludedInLayout()
@@ -305,18 +304,18 @@ This method adds a flex item (UIView) to a flex container. Internally the method
305304
```
306305
<br>
307306

308-
### addContainer()
307+
### addItem()
309308
- Applies to: `flex containers`
310309
- Returns: FlexLayout interface of the newly created flex item.
311310

312311
**Method:**
313312

314-
* **`addContainer() -> Flex`**
315-
This method is similar to `addItem()` except that it also creates the flex container's UIView. Internally the method creates a UIView, adds it has subviews and finally enables flexbox. This is useful to add a flex container easily when you don't need to refer to it later.
313+
* **`addItem() -> Flex`**
314+
This method is similar to `addItem(: UIView)` except that it also creates the flex item's UIView. Internally the method creates an UIView, adds it has subviews and enables flexbox. This is useful to add a flex item/container easily when you don't need to refer to it later.
316315

317316
###### Usage examples:
318317
```swift
319-
view.flex.addContainer().direction(.row).padding(10)
318+
view.flex.addItem().direction(.row).padding(10)
320319
```
321320
<br>
322321

@@ -331,10 +330,10 @@ This method is used to structure your code so that it matches the flexbox struct
331330

332331
###### Usage examples:
333332
```swift
334-
view.flex.addContainer().define { (flex) in
333+
view.flex.addItem().define { (flex) in
335334
flex.addItem(imageView).grow(1)
336335

337-
flex.addContainer().direction(.row).define { (flex) in
336+
flex.addItem().direction(.row).define { (flex) in
338337
flex.addItem(titleLabel).grow(1)
339338
flex.addItem(priceLabel)
340339
}
@@ -646,8 +645,7 @@ This property controls dynamically if a flexbox's UIView is included or not in t
646645

647646
FlexLayout automatically includes the UIView when:
648647
* The first time `UIView.flex` property is accessed
649-
* When a child view is added to a flexbox container using `addChild(:UIView)`
650-
* When a flexbox container is created using `addContainer()`
648+
* When a child view is added to a flexbox container using `addItem(:UIView)` or `addItem()`
651649

652650
<br>
653651

@@ -746,6 +744,7 @@ Using these properties you can control the size and position of an absolute item
746744
```swift
747745
view.flex.position(.absolute).top(10).right(10).width(100).height(50)
748746
```
747+
:pushpin: See the "Yoga C" example in the [Examples App](#examples_app). [Source code](https://github.com/lucdion/FlexLayout/blob/master/Example/FlexLayoutSample/UI/Examples/YogaExampleC/YogaExampleCView.swift)
749748

750749
<br>
751750

@@ -923,8 +922,8 @@ Set the flex item's UIView background color.
923922
###### Usage examples:
924923
```swift
925924
// Create a gray column container and add a black horizontal line separator
926-
flex.addContainer().backgroundColor(.gray).define { (flex) in
927-
flex.addContainer().height(1).backgroundColor(.black)
925+
flex.addItem().backgroundColor(.gray).define { (flex) in
926+
flex.addItem().height(1).backgroundColor(.black)
928927
}
929928
```
930929

Sources/FlexLayout.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,6 @@ public class Flex {
7676
//
7777
// Creation / definition
7878
//
79-
@discardableResult
80-
public func addContainer() -> Flex {
81-
let view = UIView()
82-
return addItem(view)
83-
}
84-
8579
@discardableResult
8680
public func addItem() -> Flex {
8781
let view = UIView()

docs/benchmark/Benchmark.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,15 @@ Remark how FlexLayout and PinLayout code is concise and clean compared to Manual
9494
```swift
9595
flex.addItem(contentView).padding(8).define { (flex) in
9696
flex.addItem(contentView).padding(8).define { (flex) in
97-
flex.addContainer().direction(.row).justifyContent(.spaceBetween).define { (flex) in
97+
flex.addItem().direction(.row).justifyContent(.spaceBetween).define { (flex) in
9898
flex.addItem(actionLabel)
9999
flex.addItem(optionsLabel)
100100
}
101101

102-
flex.addContainer().direction(.row).alignItems(.center).define({ (flex) in
102+
flex.addItem().direction(.row).alignItems(.center).define({ (flex) in
103103
flex.addItem(posterImageView).width(50).height(50).marginRight(8)
104104

105-
flex.addContainer().grow(1).define({ (flex) in
105+
flex.addItem().grow(1).define({ (flex) in
106106
flex.addItem(posterNameLabel)
107107
flex.addItem(posterHeadlineLabel)
108108
flex.addItem(posterTimeLabel)
@@ -115,13 +115,13 @@ flex.addItem(contentView).padding(8).define { (flex) in
115115
flex.addItem(contentTitleLabel)
116116
flex.addItem(contentDomainLabel)
117117

118-
flex.addContainer().direction(.row).justifyContent(.spaceBetween).marginTop(4).define({ (flex) in
118+
flex.addItem().direction(.row).justifyContent(.spaceBetween).marginTop(4).define({ (flex) in
119119
flex.addItem(likeLabel)
120120
flex.addItem(commentLabel)
121121
flex.addItem(shareLabel)
122122
})
123123

124-
flex.addContainer().direction(.row).marginTop(2).define({ (flex) in
124+
flex.addItem().direction(.row).marginTop(2).define({ (flex) in
125125
flex.addItem(actorImageView).width(50).height(50).marginRight(8)
126126
flex.addItem(actorCommentLabel).grow(1)
127127
})

0 commit comments

Comments
 (0)