Skip to content

Commit 1dd4858

Browse files
author
Luc Dion
authored
Merge pull request #9 from lucdion/update_raywenderlich_example
Update raywenderlich example to support iOS 11
2 parents 854fdd2 + 365d571 commit 1dd4858

File tree

11 files changed

+65
-162
lines changed

11 files changed

+65
-162
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
.build/
55
build/
66
xcuserdata
7-
data/
7+
Data/
88
Pods/

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Released on 2017-08-23
1515
* Added by [Luc Dion](https://github.com/lucdion) in Pull Request [#8](https://github.com/lucdion/FlexLayout/pull/8 )
1616
* Add an implementation of the Ray Wenderlich Yoga Tutorial
1717
* Added by [Luc Dion](https://github.com/lucdion) in Pull Request [#7](https://github.com/lucdion/FlexLayout/pull/7)
18+
* Add Swift 4.0 support
1819

1920
## [1.0.0](https://github.com/lucdion/FlexLayout/releases/tag/1.0.0)
2021
Released on 2017-08-20

Example/FlexLayoutSample.xcodeproj/project.pbxproj

+32-16
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
/* Begin PBXBuildFile section */
1010
2245F067A40DB6A13F97F202 /* Pods_FlexLayoutSample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 82FCE524E22C2FF5BC4DFBAB /* Pods_FlexLayoutSample.framework */; };
11-
240BE2691F4DAE0C00C89596 /* ShowTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 240BE2681F4DAE0C00C89596 /* ShowTableViewCell.swift */; };
1211
24875E611F1F929600BB1C09 /* YogaExampleCView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24875E601F1F929600BB1C09 /* YogaExampleCView.swift */; };
1312
24875E631F1F92A100BB1C09 /* YogaExampleCViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24875E621F1F92A100BB1C09 /* YogaExampleCViewController.swift */; };
1413
24875E661F1F92B500BB1C09 /* YogaExampleDView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24875E641F1F92B500BB1C09 /* YogaExampleDView.swift */; };
@@ -17,15 +16,16 @@
1716
24875E6B1F1F92C000BB1C09 /* YogaExampleEViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24875E691F1F92C000BB1C09 /* YogaExampleEViewController.swift */; };
1817
24875E701F1F92CD00BB1C09 /* FlexboxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24875E6D1F1F92CD00BB1C09 /* FlexboxViewController.swift */; };
1918
24875E711F1F92CD00BB1C09 /* MyTestView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24875E6E1F1F92CD00BB1C09 /* MyTestView.swift */; };
19+
24AADD481F4E176A00CB77E6 /* Shows.plist in Resources */ = {isa = PBXBuildFile; fileRef = 24AADD471F4E176A00CB77E6 /* Shows.plist */; };
20+
24AADD4B1F4E177700CB77E6 /* ShowTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24AADD491F4E177700CB77E6 /* ShowTableViewCell.swift */; };
21+
24AADD4C1F4E177700CB77E6 /* ExpandedTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24AADD4A1F4E177700CB77E6 /* ExpandedTableView.swift */; };
2022
24B14C5B1F278CCE00C90490 /* IntroView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24B14C591F278CCE00C90490 /* IntroView.swift */; };
2123
24B14C5C1F278CCE00C90490 /* IntroViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24B14C5A1F278CCE00C90490 /* IntroViewController.swift */; };
24+
24C0F2101F4EE9B20050BEE7 /* Show.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24C0F20F1F4EE9B20050BEE7 /* Show.swift */; };
2225
24E835161F4CC336009F95CC /* RaywenderlichTutorialView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24E835141F4CC336009F95CC /* RaywenderlichTutorialView.swift */; };
2326
24E835171F4CC336009F95CC /* RaywenderlichTutorialViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24E835151F4CC336009F95CC /* RaywenderlichTutorialViewController.swift */; };
24-
24E8351B1F4CC968009F95CC /* Show.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24E8351A1F4CC968009F95CC /* Show.swift */; };
25-
24E8351D1F4CCA02009F95CC /* Shows.plist in Resources */ = {isa = PBXBuildFile; fileRef = 24E8351C1F4CCA02009F95CC /* Shows.plist */; };
2627
DF0E852B1F1F749C00AB1956 /* YogaExampleBView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF0E85291F1F749C00AB1956 /* YogaExampleBView.swift */; };
2728
DF0E852C1F1F749C00AB1956 /* YogaExampleBViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF0E852A1F1F749C00AB1956 /* YogaExampleBViewController.swift */; };
28-
DF1F2A081F17D11700BA1B97 /* BaseFormView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24DA374A1EF7F90600D1AB2F /* BaseFormView.swift */; };
2929
DF1F2A091F17D11700BA1B97 /* MenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2439CC331E665BF6003326FB /* MenuView.swift */; };
3030
DF1F2A0A1F17D11700BA1B97 /* BaseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2493268B1EEEEFF100BCB814 /* BaseViewController.swift */; };
3131
DF1F2A0C1F17D11700BA1B97 /* BasicView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2439CC381E665C6B003326FB /* BasicView.swift */; };
@@ -55,7 +55,6 @@
5555

5656
/* Begin PBXFileReference section */
5757
0D0595B5E0950936D037ECF2 /* Pods-FlexLayoutSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FlexLayoutSample.release.xcconfig"; path = "../Pods/Target Support Files/Pods-FlexLayoutSample/Pods-FlexLayoutSample.release.xcconfig"; sourceTree = "<group>"; };
58-
240BE2681F4DAE0C00C89596 /* ShowTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ShowTableViewCell.swift; path = FlexLayoutSample/UI/Examples/RaywenderlichTutorial/ShowTableViewCell.swift; sourceTree = SOURCE_ROOT; };
5958
2439CC331E665BF6003326FB /* MenuView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MenuView.swift; sourceTree = "<group>"; };
6059
2439CC341E665BF6003326FB /* MenuViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MenuViewController.swift; sourceTree = "<group>"; };
6160
2439CC381E665C6B003326FB /* BasicView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasicView.swift; sourceTree = "<group>"; };
@@ -74,14 +73,15 @@
7473
249EFE491E64FAFE00165E39 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
7574
249EFE4C1E64FAFE00165E39 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
7675
249EFE4E1E64FAFE00165E39 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
76+
24AADD471F4E176A00CB77E6 /* Shows.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Shows.plist; path = FlexLayoutSample/UI/Examples/RaywenderlichTutorial/Data/Shows.plist; sourceTree = SOURCE_ROOT; };
77+
24AADD491F4E177700CB77E6 /* ShowTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ShowTableViewCell.swift; path = FlexLayoutSample/UI/Examples/RaywenderlichTutorial/Subviews/ShowTableViewCell.swift; sourceTree = SOURCE_ROOT; };
78+
24AADD4A1F4E177700CB77E6 /* ExpandedTableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ExpandedTableView.swift; path = FlexLayoutSample/UI/Examples/RaywenderlichTutorial/Subviews/ExpandedTableView.swift; sourceTree = SOURCE_ROOT; };
7779
24B14C591F278CCE00C90490 /* IntroView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = IntroView.swift; path = FlexLayoutSample/UI/Examples/Intro/IntroView.swift; sourceTree = SOURCE_ROOT; };
7880
24B14C5A1F278CCE00C90490 /* IntroViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = IntroViewController.swift; path = FlexLayoutSample/UI/Examples/Intro/IntroViewController.swift; sourceTree = SOURCE_ROOT; };
79-
24DA374A1EF7F90600D1AB2F /* BaseFormView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseFormView.swift; sourceTree = "<group>"; };
81+
24C0F20F1F4EE9B20050BEE7 /* Show.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Show.swift; path = FlexLayoutSample/UI/Examples/RaywenderlichTutorial/Data/Show.swift; sourceTree = SOURCE_ROOT; };
8082
24E654811E69041B00A72A8B /* Expect.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Expect.swift; sourceTree = "<group>"; };
8183
24E835141F4CC336009F95CC /* RaywenderlichTutorialView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RaywenderlichTutorialView.swift; path = FlexLayoutSample/UI/Examples/RaywenderlichTutorial/RaywenderlichTutorialView.swift; sourceTree = SOURCE_ROOT; };
8284
24E835151F4CC336009F95CC /* RaywenderlichTutorialViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RaywenderlichTutorialViewController.swift; path = FlexLayoutSample/UI/Examples/RaywenderlichTutorial/RaywenderlichTutorialViewController.swift; sourceTree = SOURCE_ROOT; };
83-
24E8351A1F4CC968009F95CC /* Show.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Show.swift; path = FlexLayoutSample/UI/Examples/RaywenderlichTutorial/Show.swift; sourceTree = SOURCE_ROOT; };
84-
24E8351C1F4CCA02009F95CC /* Shows.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Shows.plist; sourceTree = SOURCE_ROOT; };
8585
82FCE524E22C2FF5BC4DFBAB /* Pods_FlexLayoutSample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_FlexLayoutSample.framework; sourceTree = BUILT_PRODUCTS_DIR; };
8686
8561ACDBCFFA1B4B9ABEAB16 /* Pods-FlexLayoutSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FlexLayoutSample.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-FlexLayoutSample/Pods-FlexLayoutSample.debug.xcconfig"; sourceTree = "<group>"; };
8787
DF0E85291F1F749C00AB1956 /* YogaExampleBView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = YogaExampleBView.swift; path = FlexLayoutSample/UI/Examples/YogaExampleB/YogaExampleBView.swift; sourceTree = SOURCE_ROOT; };
@@ -133,7 +133,6 @@
133133
isa = PBXGroup;
134134
children = (
135135
2493268B1EEEEFF100BCB814 /* BaseViewController.swift */,
136-
24DA374A1EF7F90600D1AB2F /* BaseFormView.swift */,
137136
2493268D1EEEF02700BCB814 /* BaseView.swift */,
138137
2439CC381E665C6B003326FB /* BasicView.swift */,
139138
249326881EEEEE3D00BCB814 /* Stylesheet.swift */,
@@ -198,6 +197,24 @@
198197
path = FlexLayoutSample;
199198
sourceTree = "<group>";
200199
};
200+
24AADD451F4E16ED00CB77E6 /* Subviews */ = {
201+
isa = PBXGroup;
202+
children = (
203+
24AADD4A1F4E177700CB77E6 /* ExpandedTableView.swift */,
204+
24AADD491F4E177700CB77E6 /* ShowTableViewCell.swift */,
205+
);
206+
path = Subviews;
207+
sourceTree = "<group>";
208+
};
209+
24AADD461F4E173300CB77E6 /* Data */ = {
210+
isa = PBXGroup;
211+
children = (
212+
24C0F20F1F4EE9B20050BEE7 /* Show.swift */,
213+
24AADD471F4E176A00CB77E6 /* Shows.plist */,
214+
);
215+
path = Data;
216+
sourceTree = "<group>";
217+
};
201218
24B14C581F278CB400C90490 /* Intro */ = {
202219
isa = PBXGroup;
203220
children = (
@@ -245,11 +262,10 @@
245262
24E835131F4CC323009F95CC /* RaywenderlichTutorial */ = {
246263
isa = PBXGroup;
247264
children = (
265+
24AADD461F4E173300CB77E6 /* Data */,
266+
24AADD451F4E16ED00CB77E6 /* Subviews */,
248267
24E835141F4CC336009F95CC /* RaywenderlichTutorialView.swift */,
249268
24E835151F4CC336009F95CC /* RaywenderlichTutorialViewController.swift */,
250-
240BE2681F4DAE0C00C89596 /* ShowTableViewCell.swift */,
251-
24E8351A1F4CC968009F95CC /* Show.swift */,
252-
24E8351C1F4CCA02009F95CC /* Shows.plist */,
253269
);
254270
name = RaywenderlichTutorial;
255271
sourceTree = "<group>";
@@ -348,7 +364,7 @@
348364
buildActionMask = 2147483647;
349365
files = (
350366
DF1F2A191F17D11700BA1B97 /* LaunchScreen.storyboard in Resources */,
351-
24E8351D1F4CCA02009F95CC /* Shows.plist in Resources */,
367+
24AADD481F4E176A00CB77E6 /* Shows.plist in Resources */,
352368
DF1F2A1A1F17D11700BA1B97 /* Assets.xcassets in Resources */,
353369
);
354370
runOnlyForDeploymentPostprocessing = 0;
@@ -437,12 +453,12 @@
437453
buildActionMask = 2147483647;
438454
files = (
439455
24E835171F4CC336009F95CC /* RaywenderlichTutorialViewController.swift in Sources */,
440-
240BE2691F4DAE0C00C89596 /* ShowTableViewCell.swift in Sources */,
456+
24AADD4B1F4E177700CB77E6 /* ShowTableViewCell.swift in Sources */,
441457
DF0E852C1F1F749C00AB1956 /* YogaExampleBViewController.swift in Sources */,
442-
DF1F2A081F17D11700BA1B97 /* BaseFormView.swift in Sources */,
443458
24875E711F1F92CD00BB1C09 /* MyTestView.swift in Sources */,
444459
DF1F2A091F17D11700BA1B97 /* MenuView.swift in Sources */,
445460
DF1F2A0A1F17D11700BA1B97 /* BaseViewController.swift in Sources */,
461+
24AADD4C1F4E177700CB77E6 /* ExpandedTableView.swift in Sources */,
446462
DF91747F1F1F6F9A0034632D /* YogaExampleAView.swift in Sources */,
447463
DF1F2A0C1F17D11700BA1B97 /* BasicView.swift in Sources */,
448464
DF0E852B1F1F749C00AB1956 /* YogaExampleBView.swift in Sources */,
@@ -458,9 +474,9 @@
458474
24875E6B1F1F92C000BB1C09 /* YogaExampleEViewController.swift in Sources */,
459475
24875E661F1F92B500BB1C09 /* YogaExampleDView.swift in Sources */,
460476
24875E631F1F92A100BB1C09 /* YogaExampleCViewController.swift in Sources */,
461-
24E8351B1F4CC968009F95CC /* Show.swift in Sources */,
462477
24B14C5B1F278CCE00C90490 /* IntroView.swift in Sources */,
463478
DF1F2A101F17D11700BA1B97 /* Expect.swift in Sources */,
479+
24C0F2101F4EE9B20050BEE7 /* Show.swift in Sources */,
464480
DF1F2A111F17D11700BA1B97 /* Stylesheet.swift in Sources */,
465481
DF1F2A131F17D11700BA1B97 /* BaseView.swift in Sources */,
466482
);

Example/FlexLayoutSample/UI/Common/BaseFormView.swift

-72
This file was deleted.

Example/FlexLayoutSample/UI/Examples/RaywenderlichTutorial/RaywenderlichTutorialView.swift

+7-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class RayWenderlichTutorialView: BaseView {
2727
let summaryPopularityLabel = UILabel()
2828
let episodeTitleLabel = UILabel()
2929
let descriptionLabel = UILabel()
30-
let showsTableView = UITableView()
30+
let showsTableView = ExpandedTableView()
3131

3232
init(series: Series) {
3333
self.series = series
@@ -208,7 +208,12 @@ class RayWenderlichTutorialView: BaseView {
208208
tabView.flex.alignItems(.center).marginRight(20)
209209

210210
let tabLabelFont = selected ? UIFont.boldSystemFont(ofSize: 14.0) : UIFont.systemFont(ofSize: 14.0)
211+
212+
#if swift(>=4)
213+
let fontSize = text.size(withAttributes: [NSAttributedStringKey.font: tabLabelFont])
214+
#else
211215
let fontSize = text.size(attributes: [NSFontAttributeName: tabLabelFont])
216+
#endif
212217

213218
let tabSelectionView = UIView(frame: CGRect(x: 0, y: 0, width: fontSize.width, height: 3))
214219
tabSelectionView.flex.width(fontSize.width).marginBottom(5)
@@ -235,7 +240,7 @@ extension RayWenderlichTutorialView: UITableViewDataSource, UITableViewDelegate
235240
}
236241

237242
internal func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
238-
return 100.0
243+
return 100
239244
}
240245

241246
internal func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// File.swift
3+
// FlexLayoutSample
4+
//
5+
// Created by DION, Luc (MTL) on 2017-08-23.
6+
// Copyright © 2017 Mirego. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
// TableView that the method sizeThatFits() returns the size of all its cells.
12+
// Support only cells with fixed height
13+
class ExpandedTableView: UITableView {
14+
override func sizeThatFits(_ size: CGSize) -> CGSize {
15+
let nbOfCells = numberOfRows(inSection: 0)
16+
let cellsHeight = delegate?.tableView?(self, heightForRowAt: IndexPath(row: 0, section: 0)) ?? 0
17+
return CGSize(width: size.width, height: CGFloat(nbOfCells) * cellsHeight)
18+
}
19+
}

0 commit comments

Comments
 (0)