Skip to content

Commit 000ce8b

Browse files
committedApr 25, 2018
Add iOS project
1 parent a39763e commit 000ce8b

File tree

14 files changed

+864
-0
lines changed

14 files changed

+864
-0
lines changed
 
+347
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,347 @@
1+
// !$*UTF8*$!
2+
{
3+
archiveVersion = 1;
4+
classes = {
5+
};
6+
objectVersion = 48;
7+
objects = {
8+
9+
/* Begin PBXBuildFile section */
10+
14C2D41C208D0B50001C1229 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14C2D41B208D0B50001C1229 /* AppDelegate.swift */; };
11+
14C2D41E208D0B50001C1229 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14C2D41D208D0B50001C1229 /* ViewController.swift */; };
12+
14C2D421208D0B50001C1229 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 14C2D41F208D0B50001C1229 /* Main.storyboard */; };
13+
14C2D423208D0B50001C1229 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 14C2D422208D0B50001C1229 /* Assets.xcassets */; };
14+
14C2D426208D0B50001C1229 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 14C2D424208D0B50001C1229 /* LaunchScreen.storyboard */; };
15+
14C2D42F208D0B8D001C1229 /* DynamicValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14C2D42E208D0B8D001C1229 /* DynamicValue.swift */; };
16+
14FB2C492091181C00FF00A9 /* ColorDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14FB2C482091181C00FF00A9 /* ColorDataSource.swift */; };
17+
14FB2C4B2091184600FF00A9 /* CustomCollectionViewFlowLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14FB2C4A2091184600FF00A9 /* CustomCollectionViewFlowLayout.swift */; };
18+
/* End PBXBuildFile section */
19+
20+
/* Begin PBXFileReference section */
21+
14C2D418208D0B50001C1229 /* CollectionLayout.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CollectionLayout.app; sourceTree = BUILT_PRODUCTS_DIR; };
22+
14C2D41B208D0B50001C1229 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
23+
14C2D41D208D0B50001C1229 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
24+
14C2D420208D0B50001C1229 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
25+
14C2D422208D0B50001C1229 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
26+
14C2D425208D0B50001C1229 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
27+
14C2D427208D0B50001C1229 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
28+
14C2D42E208D0B8D001C1229 /* DynamicValue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DynamicValue.swift; sourceTree = "<group>"; };
29+
14FB2C482091181C00FF00A9 /* ColorDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorDataSource.swift; sourceTree = "<group>"; };
30+
14FB2C4A2091184600FF00A9 /* CustomCollectionViewFlowLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomCollectionViewFlowLayout.swift; sourceTree = "<group>"; };
31+
/* End PBXFileReference section */
32+
33+
/* Begin PBXFrameworksBuildPhase section */
34+
14C2D415208D0B50001C1229 /* Frameworks */ = {
35+
isa = PBXFrameworksBuildPhase;
36+
buildActionMask = 2147483647;
37+
files = (
38+
);
39+
runOnlyForDeploymentPostprocessing = 0;
40+
};
41+
/* End PBXFrameworksBuildPhase section */
42+
43+
/* Begin PBXGroup section */
44+
14C2D40F208D0B4F001C1229 = {
45+
isa = PBXGroup;
46+
children = (
47+
14C2D41A208D0B50001C1229 /* CollectionLayout */,
48+
14C2D419208D0B50001C1229 /* Products */,
49+
);
50+
sourceTree = "<group>";
51+
};
52+
14C2D419208D0B50001C1229 /* Products */ = {
53+
isa = PBXGroup;
54+
children = (
55+
14C2D418208D0B50001C1229 /* CollectionLayout.app */,
56+
);
57+
name = Products;
58+
sourceTree = "<group>";
59+
};
60+
14C2D41A208D0B50001C1229 /* CollectionLayout */ = {
61+
isa = PBXGroup;
62+
children = (
63+
14C2D42D208D0B83001C1229 /* Model */,
64+
14C2D41B208D0B50001C1229 /* AppDelegate.swift */,
65+
14C2D41D208D0B50001C1229 /* ViewController.swift */,
66+
14C2D41F208D0B50001C1229 /* Main.storyboard */,
67+
14C2D422208D0B50001C1229 /* Assets.xcassets */,
68+
14C2D424208D0B50001C1229 /* LaunchScreen.storyboard */,
69+
14C2D427208D0B50001C1229 /* Info.plist */,
70+
14FB2C482091181C00FF00A9 /* ColorDataSource.swift */,
71+
14FB2C4A2091184600FF00A9 /* CustomCollectionViewFlowLayout.swift */,
72+
);
73+
path = CollectionLayout;
74+
sourceTree = "<group>";
75+
};
76+
14C2D42D208D0B83001C1229 /* Model */ = {
77+
isa = PBXGroup;
78+
children = (
79+
14C2D42E208D0B8D001C1229 /* DynamicValue.swift */,
80+
);
81+
path = Model;
82+
sourceTree = "<group>";
83+
};
84+
/* End PBXGroup section */
85+
86+
/* Begin PBXNativeTarget section */
87+
14C2D417208D0B50001C1229 /* CollectionLayout */ = {
88+
isa = PBXNativeTarget;
89+
buildConfigurationList = 14C2D42A208D0B50001C1229 /* Build configuration list for PBXNativeTarget "CollectionLayout" */;
90+
buildPhases = (
91+
14C2D414208D0B50001C1229 /* Sources */,
92+
14C2D415208D0B50001C1229 /* Frameworks */,
93+
14C2D416208D0B50001C1229 /* Resources */,
94+
);
95+
buildRules = (
96+
);
97+
dependencies = (
98+
);
99+
name = CollectionLayout;
100+
productName = CollectionLayout;
101+
productReference = 14C2D418208D0B50001C1229 /* CollectionLayout.app */;
102+
productType = "com.apple.product-type.application";
103+
};
104+
/* End PBXNativeTarget section */
105+
106+
/* Begin PBXProject section */
107+
14C2D410208D0B4F001C1229 /* Project object */ = {
108+
isa = PBXProject;
109+
attributes = {
110+
LastSwiftUpdateCheck = 0920;
111+
LastUpgradeCheck = 0920;
112+
ORGANIZATIONNAME = "Benoit PASQUIER";
113+
TargetAttributes = {
114+
14C2D417208D0B50001C1229 = {
115+
CreatedOnToolsVersion = 9.2;
116+
ProvisioningStyle = Automatic;
117+
};
118+
};
119+
};
120+
buildConfigurationList = 14C2D413208D0B4F001C1229 /* Build configuration list for PBXProject "CollectionLayout" */;
121+
compatibilityVersion = "Xcode 8.0";
122+
developmentRegion = en;
123+
hasScannedForEncodings = 0;
124+
knownRegions = (
125+
en,
126+
Base,
127+
);
128+
mainGroup = 14C2D40F208D0B4F001C1229;
129+
productRefGroup = 14C2D419208D0B50001C1229 /* Products */;
130+
projectDirPath = "";
131+
projectRoot = "";
132+
targets = (
133+
14C2D417208D0B50001C1229 /* CollectionLayout */,
134+
);
135+
};
136+
/* End PBXProject section */
137+
138+
/* Begin PBXResourcesBuildPhase section */
139+
14C2D416208D0B50001C1229 /* Resources */ = {
140+
isa = PBXResourcesBuildPhase;
141+
buildActionMask = 2147483647;
142+
files = (
143+
14C2D426208D0B50001C1229 /* LaunchScreen.storyboard in Resources */,
144+
14C2D423208D0B50001C1229 /* Assets.xcassets in Resources */,
145+
14C2D421208D0B50001C1229 /* Main.storyboard in Resources */,
146+
);
147+
runOnlyForDeploymentPostprocessing = 0;
148+
};
149+
/* End PBXResourcesBuildPhase section */
150+
151+
/* Begin PBXSourcesBuildPhase section */
152+
14C2D414208D0B50001C1229 /* Sources */ = {
153+
isa = PBXSourcesBuildPhase;
154+
buildActionMask = 2147483647;
155+
files = (
156+
14C2D41E208D0B50001C1229 /* ViewController.swift in Sources */,
157+
14C2D42F208D0B8D001C1229 /* DynamicValue.swift in Sources */,
158+
14FB2C492091181C00FF00A9 /* ColorDataSource.swift in Sources */,
159+
14FB2C4B2091184600FF00A9 /* CustomCollectionViewFlowLayout.swift in Sources */,
160+
14C2D41C208D0B50001C1229 /* AppDelegate.swift in Sources */,
161+
);
162+
runOnlyForDeploymentPostprocessing = 0;
163+
};
164+
/* End PBXSourcesBuildPhase section */
165+
166+
/* Begin PBXVariantGroup section */
167+
14C2D41F208D0B50001C1229 /* Main.storyboard */ = {
168+
isa = PBXVariantGroup;
169+
children = (
170+
14C2D420208D0B50001C1229 /* Base */,
171+
);
172+
name = Main.storyboard;
173+
sourceTree = "<group>";
174+
};
175+
14C2D424208D0B50001C1229 /* LaunchScreen.storyboard */ = {
176+
isa = PBXVariantGroup;
177+
children = (
178+
14C2D425208D0B50001C1229 /* Base */,
179+
);
180+
name = LaunchScreen.storyboard;
181+
sourceTree = "<group>";
182+
};
183+
/* End PBXVariantGroup section */
184+
185+
/* Begin XCBuildConfiguration section */
186+
14C2D428208D0B50001C1229 /* Debug */ = {
187+
isa = XCBuildConfiguration;
188+
buildSettings = {
189+
ALWAYS_SEARCH_USER_PATHS = NO;
190+
CLANG_ANALYZER_NONNULL = YES;
191+
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
192+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
193+
CLANG_CXX_LIBRARY = "libc++";
194+
CLANG_ENABLE_MODULES = YES;
195+
CLANG_ENABLE_OBJC_ARC = YES;
196+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
197+
CLANG_WARN_BOOL_CONVERSION = YES;
198+
CLANG_WARN_COMMA = YES;
199+
CLANG_WARN_CONSTANT_CONVERSION = YES;
200+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
201+
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
202+
CLANG_WARN_EMPTY_BODY = YES;
203+
CLANG_WARN_ENUM_CONVERSION = YES;
204+
CLANG_WARN_INFINITE_RECURSION = YES;
205+
CLANG_WARN_INT_CONVERSION = YES;
206+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
207+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
208+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
209+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
210+
CLANG_WARN_STRICT_PROTOTYPES = YES;
211+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
212+
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
213+
CLANG_WARN_UNREACHABLE_CODE = YES;
214+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
215+
CODE_SIGN_IDENTITY = "iPhone Developer";
216+
COPY_PHASE_STRIP = NO;
217+
DEBUG_INFORMATION_FORMAT = dwarf;
218+
ENABLE_STRICT_OBJC_MSGSEND = YES;
219+
ENABLE_TESTABILITY = YES;
220+
GCC_C_LANGUAGE_STANDARD = gnu11;
221+
GCC_DYNAMIC_NO_PIC = NO;
222+
GCC_NO_COMMON_BLOCKS = YES;
223+
GCC_OPTIMIZATION_LEVEL = 0;
224+
GCC_PREPROCESSOR_DEFINITIONS = (
225+
"DEBUG=1",
226+
"$(inherited)",
227+
);
228+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
229+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
230+
GCC_WARN_UNDECLARED_SELECTOR = YES;
231+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
232+
GCC_WARN_UNUSED_FUNCTION = YES;
233+
GCC_WARN_UNUSED_VARIABLE = YES;
234+
IPHONEOS_DEPLOYMENT_TARGET = 11.2;
235+
MTL_ENABLE_DEBUG_INFO = YES;
236+
ONLY_ACTIVE_ARCH = YES;
237+
SDKROOT = iphoneos;
238+
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
239+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
240+
};
241+
name = Debug;
242+
};
243+
14C2D429208D0B50001C1229 /* Release */ = {
244+
isa = XCBuildConfiguration;
245+
buildSettings = {
246+
ALWAYS_SEARCH_USER_PATHS = NO;
247+
CLANG_ANALYZER_NONNULL = YES;
248+
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
249+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
250+
CLANG_CXX_LIBRARY = "libc++";
251+
CLANG_ENABLE_MODULES = YES;
252+
CLANG_ENABLE_OBJC_ARC = YES;
253+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
254+
CLANG_WARN_BOOL_CONVERSION = YES;
255+
CLANG_WARN_COMMA = YES;
256+
CLANG_WARN_CONSTANT_CONVERSION = YES;
257+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
258+
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
259+
CLANG_WARN_EMPTY_BODY = YES;
260+
CLANG_WARN_ENUM_CONVERSION = YES;
261+
CLANG_WARN_INFINITE_RECURSION = YES;
262+
CLANG_WARN_INT_CONVERSION = YES;
263+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
264+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
265+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
266+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
267+
CLANG_WARN_STRICT_PROTOTYPES = YES;
268+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
269+
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
270+
CLANG_WARN_UNREACHABLE_CODE = YES;
271+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
272+
CODE_SIGN_IDENTITY = "iPhone Developer";
273+
COPY_PHASE_STRIP = NO;
274+
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
275+
ENABLE_NS_ASSERTIONS = NO;
276+
ENABLE_STRICT_OBJC_MSGSEND = YES;
277+
GCC_C_LANGUAGE_STANDARD = gnu11;
278+
GCC_NO_COMMON_BLOCKS = YES;
279+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
280+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
281+
GCC_WARN_UNDECLARED_SELECTOR = YES;
282+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
283+
GCC_WARN_UNUSED_FUNCTION = YES;
284+
GCC_WARN_UNUSED_VARIABLE = YES;
285+
IPHONEOS_DEPLOYMENT_TARGET = 11.2;
286+
MTL_ENABLE_DEBUG_INFO = NO;
287+
SDKROOT = iphoneos;
288+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
289+
VALIDATE_PRODUCT = YES;
290+
};
291+
name = Release;
292+
};
293+
14C2D42B208D0B50001C1229 /* Debug */ = {
294+
isa = XCBuildConfiguration;
295+
buildSettings = {
296+
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
297+
CODE_SIGN_STYLE = Automatic;
298+
DEVELOPMENT_TEAM = XG3URJ46HG;
299+
INFOPLIST_FILE = CollectionLayout/Info.plist;
300+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
301+
PRODUCT_BUNDLE_IDENTIFIER = fr.benoitpasquier.CollectionLayout;
302+
PRODUCT_NAME = "$(TARGET_NAME)";
303+
SWIFT_VERSION = 4.0;
304+
TARGETED_DEVICE_FAMILY = "1,2";
305+
};
306+
name = Debug;
307+
};
308+
14C2D42C208D0B50001C1229 /* Release */ = {
309+
isa = XCBuildConfiguration;
310+
buildSettings = {
311+
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
312+
CODE_SIGN_STYLE = Automatic;
313+
DEVELOPMENT_TEAM = XG3URJ46HG;
314+
INFOPLIST_FILE = CollectionLayout/Info.plist;
315+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
316+
PRODUCT_BUNDLE_IDENTIFIER = fr.benoitpasquier.CollectionLayout;
317+
PRODUCT_NAME = "$(TARGET_NAME)";
318+
SWIFT_VERSION = 4.0;
319+
TARGETED_DEVICE_FAMILY = "1,2";
320+
};
321+
name = Release;
322+
};
323+
/* End XCBuildConfiguration section */
324+
325+
/* Begin XCConfigurationList section */
326+
14C2D413208D0B4F001C1229 /* Build configuration list for PBXProject "CollectionLayout" */ = {
327+
isa = XCConfigurationList;
328+
buildConfigurations = (
329+
14C2D428208D0B50001C1229 /* Debug */,
330+
14C2D429208D0B50001C1229 /* Release */,
331+
);
332+
defaultConfigurationIsVisible = 0;
333+
defaultConfigurationName = Release;
334+
};
335+
14C2D42A208D0B50001C1229 /* Build configuration list for PBXNativeTarget "CollectionLayout" */ = {
336+
isa = XCConfigurationList;
337+
buildConfigurations = (
338+
14C2D42B208D0B50001C1229 /* Debug */,
339+
14C2D42C208D0B50001C1229 /* Release */,
340+
);
341+
defaultConfigurationIsVisible = 0;
342+
defaultConfigurationName = Release;
343+
};
344+
/* End XCConfigurationList section */
345+
};
346+
rootObject = 14C2D410208D0B4F001C1229 /* Project object */;
347+
}

‎CollectionLayout.xcodeproj/project.xcworkspace/contents.xcworkspacedata

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Bucket
3+
type = "1"
4+
version = "2.0">
5+
</Bucket>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>SchemeUserState</key>
6+
<dict>
7+
<key>CollectionLayout.xcscheme</key>
8+
<dict>
9+
<key>orderHint</key>
10+
<integer>0</integer>
11+
</dict>
12+
</dict>
13+
</dict>
14+
</plist>

‎CollectionLayout/AppDelegate.swift

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//
2+
// AppDelegate.swift
3+
// CollectionLayout
4+
//
5+
// Created by Benoit PASQUIER on 22/04/2018.
6+
// Copyright © 2018 Benoit PASQUIER. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
@UIApplicationMain
12+
class AppDelegate: UIResponder, UIApplicationDelegate {
13+
14+
var window: UIWindow?
15+
16+
17+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
18+
// Override point for customization after application launch.
19+
return true
20+
}
21+
22+
func applicationWillResignActive(_ application: UIApplication) {
23+
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
24+
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
25+
}
26+
27+
func applicationDidEnterBackground(_ application: UIApplication) {
28+
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
29+
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30+
}
31+
32+
func applicationWillEnterForeground(_ application: UIApplication) {
33+
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
34+
}
35+
36+
func applicationDidBecomeActive(_ application: UIApplication) {
37+
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
38+
}
39+
40+
func applicationWillTerminate(_ application: UIApplication) {
41+
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
42+
}
43+
44+
45+
}
46+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"size" : "20x20",
6+
"scale" : "2x"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"size" : "20x20",
11+
"scale" : "3x"
12+
},
13+
{
14+
"idiom" : "iphone",
15+
"size" : "29x29",
16+
"scale" : "2x"
17+
},
18+
{
19+
"idiom" : "iphone",
20+
"size" : "29x29",
21+
"scale" : "3x"
22+
},
23+
{
24+
"idiom" : "iphone",
25+
"size" : "40x40",
26+
"scale" : "2x"
27+
},
28+
{
29+
"idiom" : "iphone",
30+
"size" : "40x40",
31+
"scale" : "3x"
32+
},
33+
{
34+
"idiom" : "iphone",
35+
"size" : "60x60",
36+
"scale" : "2x"
37+
},
38+
{
39+
"idiom" : "iphone",
40+
"size" : "60x60",
41+
"scale" : "3x"
42+
},
43+
{
44+
"idiom" : "ipad",
45+
"size" : "20x20",
46+
"scale" : "1x"
47+
},
48+
{
49+
"idiom" : "ipad",
50+
"size" : "20x20",
51+
"scale" : "2x"
52+
},
53+
{
54+
"idiom" : "ipad",
55+
"size" : "29x29",
56+
"scale" : "1x"
57+
},
58+
{
59+
"idiom" : "ipad",
60+
"size" : "29x29",
61+
"scale" : "2x"
62+
},
63+
{
64+
"idiom" : "ipad",
65+
"size" : "40x40",
66+
"scale" : "1x"
67+
},
68+
{
69+
"idiom" : "ipad",
70+
"size" : "40x40",
71+
"scale" : "2x"
72+
},
73+
{
74+
"idiom" : "ipad",
75+
"size" : "76x76",
76+
"scale" : "1x"
77+
},
78+
{
79+
"idiom" : "ipad",
80+
"size" : "76x76",
81+
"scale" : "2x"
82+
},
83+
{
84+
"idiom" : "ipad",
85+
"size" : "83.5x83.5",
86+
"scale" : "2x"
87+
}
88+
],
89+
"info" : {
90+
"version" : 1,
91+
"author" : "xcode"
92+
}
93+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" systemVersion="17A277" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
5+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
6+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
7+
</dependencies>
8+
<scenes>
9+
<!--View Controller-->
10+
<scene sceneID="EHf-IW-A2E">
11+
<objects>
12+
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
13+
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
14+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
15+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
16+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
17+
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
18+
</view>
19+
</viewController>
20+
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
21+
</objects>
22+
<point key="canvasLocation" x="53" y="375"/>
23+
</scene>
24+
</scenes>
25+
</document>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="zIQ-AA-MWK">
3+
<device id="retina4_7" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
6+
<dependencies>
7+
<deployment identifier="iOS"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
9+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
10+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
11+
</dependencies>
12+
<scenes>
13+
<!--View Controller-->
14+
<scene sceneID="tne-QT-ifu">
15+
<objects>
16+
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="CollectionLayout" customModuleProvider="target" sceneMemberID="viewController">
17+
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
18+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
19+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
20+
<subviews>
21+
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="qoE-zy-Lhd">
22+
<rect key="frame" x="0.0" y="144" width="375" height="523"/>
23+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
24+
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="osz-cE-G6i">
25+
<size key="itemSize" width="50" height="50"/>
26+
<size key="headerReferenceSize" width="0.0" height="0.0"/>
27+
<size key="footerReferenceSize" width="0.0" height="0.0"/>
28+
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
29+
</collectionViewFlowLayout>
30+
<cells>
31+
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="ColorCell" id="aqr-cv-4Sc">
32+
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
33+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
34+
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO">
35+
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
36+
<autoresizingMask key="autoresizingMask"/>
37+
</view>
38+
</collectionViewCell>
39+
</cells>
40+
</collectionView>
41+
<segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="uuO-Iq-1X4">
42+
<rect key="frame" x="62" y="84" width="250" height="41"/>
43+
<constraints>
44+
<constraint firstAttribute="width" constant="250" id="ftc-fc-cCS"/>
45+
<constraint firstAttribute="height" constant="40" id="wWJ-px-ZqR"/>
46+
</constraints>
47+
<segments>
48+
<segment title="Grid"/>
49+
<segment title="List"/>
50+
<segment title="Inline"/>
51+
</segments>
52+
<connections>
53+
<action selector="layoutValueChanged:" destination="BYZ-38-t0r" eventType="valueChanged" id="i4d-Cd-Ekt"/>
54+
</connections>
55+
</segmentedControl>
56+
</subviews>
57+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
58+
<constraints>
59+
<constraint firstItem="qoE-zy-Lhd" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" id="8TW-Kb-X0m"/>
60+
<constraint firstItem="qoE-zy-Lhd" firstAttribute="top" secondItem="uuO-Iq-1X4" secondAttribute="bottom" constant="20" id="Kix-qd-Dql"/>
61+
<constraint firstItem="6Tk-OE-BBY" firstAttribute="bottom" secondItem="qoE-zy-Lhd" secondAttribute="bottom" id="Udr-IE-QUV"/>
62+
<constraint firstItem="uuO-Iq-1X4" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="jBI-QU-OLb"/>
63+
<constraint firstItem="uuO-Iq-1X4" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" constant="20" id="uWW-ZJ-ogV"/>
64+
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="qoE-zy-Lhd" secondAttribute="trailing" id="ukm-49-gry"/>
65+
</constraints>
66+
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
67+
</view>
68+
<navigationItem key="navigationItem" id="Fsb-MK-9sN"/>
69+
<connections>
70+
<outlet property="collectionView" destination="qoE-zy-Lhd" id="GZ1-yJ-5vr"/>
71+
</connections>
72+
</viewController>
73+
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
74+
</objects>
75+
<point key="canvasLocation" x="256.80000000000001" y="135.38230884557723"/>
76+
</scene>
77+
<!--Navigation Controller-->
78+
<scene sceneID="Ueu-fL-Bni">
79+
<objects>
80+
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="zIQ-AA-MWK" sceneMemberID="viewController">
81+
<toolbarItems/>
82+
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="hWi-0k-qJg">
83+
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
84+
<autoresizingMask key="autoresizingMask"/>
85+
</navigationBar>
86+
<nil name="viewControllers"/>
87+
<connections>
88+
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="dXF-B1-sH0"/>
89+
</connections>
90+
</navigationController>
91+
<placeholder placeholderIdentifier="IBFirstResponder" id="pvI-YG-QiQ" userLabel="First Responder" sceneMemberID="firstResponder"/>
92+
</objects>
93+
<point key="canvasLocation" x="-479" y="135"/>
94+
</scene>
95+
</scenes>
96+
</document>
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// ColorDataSource.swift
3+
// CollectionLayout
4+
//
5+
// Created by Benoit PASQUIER on 25/04/2018.
6+
// Copyright © 2018 Benoit PASQUIER. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import UIKit
11+
12+
class GenericDataSource<T> : NSObject {
13+
var data: DynamicValue<[T]> = DynamicValue([])
14+
}
15+
16+
class ColorDataSource : GenericDataSource<UIColor>, UICollectionViewDataSource {
17+
18+
func numberOfSections(in collectionView: UICollectionView) -> Int {
19+
return 1
20+
}
21+
22+
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
23+
return data.value.count
24+
}
25+
26+
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
27+
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ColorCell", for: indexPath)
28+
29+
cell.backgroundColor = data.value[indexPath.row]
30+
return cell
31+
}
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
//
2+
// CustomCollectionViewLayout.swift
3+
// CollectionLayout
4+
//
5+
// Created by Benoit PASQUIER on 25/04/2018.
6+
// Copyright © 2018 Benoit PASQUIER. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import UIKit
11+
12+
enum CollectionDisplay {
13+
case inline
14+
case list
15+
case grid
16+
}
17+
18+
class CustomCollectionViewFlowLayout : UICollectionViewFlowLayout {
19+
20+
var display : CollectionDisplay = .grid {
21+
didSet {
22+
if display != oldValue {
23+
self.invalidateLayout()
24+
}
25+
}
26+
}
27+
28+
convenience init(display: CollectionDisplay) {
29+
self.init()
30+
31+
self.display = display
32+
self.minimumLineSpacing = 10
33+
self.minimumInteritemSpacing = 10
34+
self.configLayout()
35+
}
36+
37+
func configLayout() {
38+
switch display {
39+
case .inline:
40+
self.scrollDirection = .horizontal
41+
if let collectionView = self.collectionView {
42+
self.itemSize = CGSize(width: collectionView.frame.width * 0.9, height: 300)
43+
}
44+
45+
case .grid:
46+
47+
self.scrollDirection = .vertical
48+
if let collectionView = self.collectionView {
49+
let optimisedWidth = (collectionView.frame.width - minimumInteritemSpacing) / 2
50+
self.itemSize = CGSize(width: optimisedWidth , height: optimisedWidth) // keep as square
51+
}
52+
53+
case .list:
54+
self.scrollDirection = .vertical
55+
if let collectionView = self.collectionView {
56+
self.itemSize = CGSize(width: collectionView.frame.width , height: 130)
57+
}
58+
}
59+
}
60+
61+
override func invalidateLayout() {
62+
super.invalidateLayout()
63+
self.configLayout()
64+
}
65+
}

‎CollectionLayout/Info.plist

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>$(DEVELOPMENT_LANGUAGE)</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>APPL</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>1.0</string>
19+
<key>CFBundleVersion</key>
20+
<string>1</string>
21+
<key>LSRequiresIPhoneOS</key>
22+
<true/>
23+
<key>UILaunchStoryboardName</key>
24+
<string>LaunchScreen</string>
25+
<key>UIMainStoryboardFile</key>
26+
<string>Main</string>
27+
<key>UIRequiredDeviceCapabilities</key>
28+
<array>
29+
<string>armv7</string>
30+
</array>
31+
<key>UISupportedInterfaceOrientations</key>
32+
<array>
33+
<string>UIInterfaceOrientationPortrait</string>
34+
<string>UIInterfaceOrientationLandscapeLeft</string>
35+
<string>UIInterfaceOrientationLandscapeRight</string>
36+
</array>
37+
<key>UISupportedInterfaceOrientations~ipad</key>
38+
<array>
39+
<string>UIInterfaceOrientationPortrait</string>
40+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
41+
<string>UIInterfaceOrientationLandscapeLeft</string>
42+
<string>UIInterfaceOrientationLandscapeRight</string>
43+
</array>
44+
</dict>
45+
</plist>
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//
2+
// DynamicValue.swift
3+
// CollectionLayout
4+
//
5+
// Created by Benoit PASQUIER on 22/04/2018.
6+
// Copyright © 2018 Benoit PASQUIER. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
typealias CompletionHandler = (() -> Void)
12+
class DynamicValue<T> {
13+
14+
var value : T {
15+
didSet {
16+
self.notify()
17+
}
18+
}
19+
20+
private var observers = [String: CompletionHandler]()
21+
22+
init(_ value: T) {
23+
self.value = value
24+
}
25+
26+
public func addObserver(_ observer: NSObject, completionHandler: @escaping CompletionHandler) {
27+
observers[observer.description] = completionHandler
28+
}
29+
30+
public func addAndNotify(observer: NSObject, completionHandler: @escaping CompletionHandler) {
31+
self.addObserver(observer, completionHandler: completionHandler)
32+
self.notify()
33+
}
34+
35+
private func notify() {
36+
observers.forEach({ $0.value() })
37+
}
38+
39+
deinit {
40+
observers.removeAll()
41+
}
42+
}

‎CollectionLayout/ViewController.swift

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//
2+
// ViewController.swift
3+
// CollectionLayout
4+
//
5+
// Created by Benoit PASQUIER on 22/04/2018.
6+
// Copyright © 2018 Benoit PASQUIER. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
class ViewController: UIViewController {
12+
13+
@IBOutlet weak var collectionView : UICollectionView!
14+
15+
lazy var collectionViewFlowLayout : CustomCollectionViewFlowLayout = {
16+
let layout = CustomCollectionViewFlowLayout(display: .grid)
17+
return layout
18+
}()
19+
20+
let dataSource = ColorDataSource()
21+
22+
override func viewDidLoad() {
23+
super.viewDidLoad()
24+
// Do any additional setup after loading the view, typically from a nib.
25+
26+
self.collectionView.collectionViewLayout = self.collectionViewFlowLayout
27+
self.collectionView.dataSource = self.dataSource
28+
29+
self.dataSource.data.addAndNotify(observer: self) { [weak self] in
30+
self?.collectionView.reloadData()
31+
}
32+
33+
self.dataSource.data.value = [.red, .orange, .cyan, .purple, .yellow, .magenta]
34+
}
35+
36+
@IBAction func layoutValueChanged(_ sender: UISegmentedControl) {
37+
38+
switch sender.selectedSegmentIndex {
39+
case 1:
40+
self.collectionViewFlowLayout.display = .list
41+
case 2:
42+
self.collectionViewFlowLayout.display = .inline
43+
default:
44+
self.collectionViewFlowLayout.display = .grid
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)
Please sign in to comment.