Skip to content

Commit fbfdd57

Browse files
author
Jim Puls
committed
Merge pull request #2 from ios/puls/test-app
Test app and other recruiting trip changes
2 parents da99ffa + 999a464 commit fbfdd57

File tree

141 files changed

+2310
-256
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+2310
-256
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
xcuserdata
22
.DS_Store
3+
*.xccheckout
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="4514" systemVersion="13B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="INF-sx-8CY">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3747"/>
5+
</dependencies>
6+
<scenes>
7+
<!--Master View Controller-->
8+
<scene sceneID="3xf-CV-b2Z">
9+
<objects>
10+
<collectionViewController storyboardIdentifier="Master View Controller" autoresizesArchivedViewToFullSize="NO" id="UH6-2k-Soh" customClass="CGTAMasterViewController" sceneMemberID="viewController">
11+
<collectionView key="view" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" minimumZoomScale="0.0" maximumZoomScale="0.0" dataMode="prototypes" id="Ckj-MB-u4F">
12+
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
13+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
14+
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="0.0" minimumInteritemSpacing="0.0" id="A42-Go-8PB">
15+
<size key="itemSize" width="160" height="160"/>
16+
<size key="headerReferenceSize" width="0.0" height="0.0"/>
17+
<size key="footerReferenceSize" width="0.0" height="0.0"/>
18+
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
19+
</collectionViewFlowLayout>
20+
<cells>
21+
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="Image Cell" id="mZg-o6-U32" customClass="CGTAFlagCollectionViewCell">
22+
<rect key="frame" x="0.0" y="64" width="160" height="160"/>
23+
<autoresizingMask key="autoresizingMask"/>
24+
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
25+
<rect key="frame" x="0.0" y="0.0" width="160" height="160"/>
26+
<autoresizingMask key="autoresizingMask"/>
27+
<subviews>
28+
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="USA" translatesAutoresizingMaskIntoConstraints="NO" id="LPM-aq-eVP">
29+
<rect key="frame" x="0.0" y="0.0" width="160" height="160"/>
30+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
31+
</imageView>
32+
</subviews>
33+
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
34+
</view>
35+
<constraints>
36+
<constraint firstAttribute="bottom" secondItem="LPM-aq-eVP" secondAttribute="bottom" id="3dC-zy-EKj"/>
37+
<constraint firstItem="LPM-aq-eVP" firstAttribute="leading" secondItem="mZg-o6-U32" secondAttribute="leading" id="CUC-Zi-AO2"/>
38+
<constraint firstAttribute="trailing" secondItem="LPM-aq-eVP" secondAttribute="trailing" id="eON-IQ-OZe"/>
39+
<constraint firstItem="LPM-aq-eVP" firstAttribute="top" secondItem="mZg-o6-U32" secondAttribute="top" id="rr5-Ix-vFh"/>
40+
</constraints>
41+
<connections>
42+
<outlet property="imageView" destination="LPM-aq-eVP" id="4Wu-rt-zSB"/>
43+
<segue destination="Ah7-4n-0Wa" kind="push" identifier="Tap on Flag" id="e5Y-SN-UWY"/>
44+
</connections>
45+
</collectionViewCell>
46+
</cells>
47+
<connections>
48+
<outlet property="dataSource" destination="UH6-2k-Soh" id="m1v-tP-KJh"/>
49+
<outlet property="delegate" destination="UH6-2k-Soh" id="b0C-Mp-1P8"/>
50+
</connections>
51+
</collectionView>
52+
<navigationItem key="navigationItem" id="teh-qR-8dZ">
53+
<nil key="title"/>
54+
<slider key="titleView" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="120" minValue="0.0" maxValue="160" id="sg9-qZ-59e">
55+
<rect key="frame" x="8" y="8" width="304" height="29"/>
56+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
57+
<color key="minimumTrackTintColor" red="0.0" green="0.74117648601531982" blue="0.64313727617263794" alpha="1" colorSpace="deviceRGB"/>
58+
<connections>
59+
<action selector="sliderValueChanged:" destination="UH6-2k-Soh" eventType="valueChanged" id="Tfs-NO-5oy"/>
60+
</connections>
61+
</slider>
62+
</navigationItem>
63+
<connections>
64+
<outlet property="cellSizeSlider" destination="sg9-qZ-59e" id="gwU-KP-c6P"/>
65+
</connections>
66+
</collectionViewController>
67+
<placeholder placeholderIdentifier="IBFirstResponder" id="eQs-he-B5Z" userLabel="First Responder" sceneMemberID="firstResponder"/>
68+
</objects>
69+
<point key="canvasLocation" x="881" y="64"/>
70+
</scene>
71+
<!--Detail View Controller - Detail-->
72+
<scene sceneID="Cn3-H9-jdl">
73+
<objects>
74+
<viewController title="Detail" id="Ah7-4n-0Wa" customClass="CGTADetailViewController" sceneMemberID="viewController">
75+
<layoutGuides>
76+
<viewControllerLayoutGuide type="top" id="EK1-eN-tCq"/>
77+
<viewControllerLayoutGuide type="bottom" id="wQM-DP-Tgk"/>
78+
</layoutGuides>
79+
<view key="view" contentMode="scaleToFill" id="MMQ-IT-qOo">
80+
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
81+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
82+
<subviews>
83+
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="cK7-Bz-0X1">
84+
<rect key="frame" x="0.0" y="1" width="320" height="568"/>
85+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
86+
</imageView>
87+
</subviews>
88+
</view>
89+
<navigationItem key="navigationItem" title="Detail" id="cra-N8-TIN"/>
90+
<connections>
91+
<outlet property="imageView" destination="cK7-Bz-0X1" id="dbA-f5-cQY"/>
92+
</connections>
93+
</viewController>
94+
<placeholder placeholderIdentifier="IBFirstResponder" id="lrm-kH-fPn" sceneMemberID="firstResponder"/>
95+
</objects>
96+
<point key="canvasLocation" x="1428" y="64"/>
97+
</scene>
98+
<!--Navigation Controller-->
99+
<scene sceneID="Gwc-n1-nXR">
100+
<objects>
101+
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="INF-sx-8CY" sceneMemberID="viewController">
102+
<toolbarItems/>
103+
<navigationBar key="navigationBar" contentMode="scaleToFill" id="rje-BN-VLD">
104+
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
105+
<autoresizingMask key="autoresizingMask"/>
106+
<color key="tintColor" red="0.0" green="0.74117648601531982" blue="0.64313727617263794" alpha="1" colorSpace="deviceRGB"/>
107+
<textAttributes key="titleTextAttributes">
108+
<color key="textColor" red="0.0" green="0.74117648601531982" blue="0.64313727617263794" alpha="1" colorSpace="deviceRGB"/>
109+
</textAttributes>
110+
</navigationBar>
111+
<nil name="viewControllers"/>
112+
<connections>
113+
<segue destination="UH6-2k-Soh" kind="relationship" relationship="rootViewController" id="2pt-sd-z5Z"/>
114+
</connections>
115+
</navigationController>
116+
<placeholder placeholderIdentifier="IBFirstResponder" id="dXu-Dv-wXY" userLabel="First Responder" sceneMemberID="firstResponder"/>
117+
</objects>
118+
<point key="canvasLocation" x="478" y="64"/>
119+
</scene>
120+
</scenes>
121+
<resources>
122+
<image name="USA" width="128" height="128"/>
123+
</resources>
124+
<simulatedMetricsContainer key="defaultSimulatedMetrics">
125+
<simulatedStatusBarMetrics key="statusBar"/>
126+
<simulatedOrientationMetrics key="orientation"/>
127+
<simulatedScreenMetrics key="destination" type="retina4"/>
128+
</simulatedMetricsContainer>
129+
</document>

CodeGenTestApp/CGTAAppDelegate.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// CGTAAppDelegate.h
3+
// CodeGenTestApp
4+
//
5+
// Created by Jim Puls on 2/3/14.
6+
// Licensed to Square, Inc. under one or more contributor license agreements.
7+
// See the LICENSE file distributed with this work for the terms under
8+
// which Square, Inc. licenses this file to you.
9+
10+
11+
@interface CGTAAppDelegate : UIResponder <UIApplicationDelegate>
12+
13+
@property (strong, nonatomic) UIWindow *window;
14+
15+
@end

CodeGenTestApp/CGTAAppDelegate.m

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// CGTAAppDelegate.m
3+
// CodeGenTestApp
4+
//
5+
// Created by Jim Puls on 2/3/14.
6+
// Licensed to Square, Inc. under one or more contributor license agreements.
7+
// See the LICENSE file distributed with this work for the terms under
8+
// which Square, Inc. licenses this file to you.
9+
10+
#import "CGTAAppDelegate.h"
11+
12+
@implementation CGTAAppDelegate
13+
@end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// CGTADetailViewController.h
3+
// CodeGenTestApp
4+
//
5+
// Created by Jim Puls on 2/3/14.
6+
// Licensed to Square, Inc. under one or more contributor license agreements.
7+
// See the LICENSE file distributed with this work for the terms under
8+
// which Square, Inc. licenses this file to you.
9+
10+
11+
@interface CGTADetailViewController : UIViewController
12+
13+
@property (nonatomic, strong) UIImage *image;
14+
15+
@end
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//
2+
// CGTADetailViewController.m
3+
// CodeGenTestApp
4+
//
5+
// Created by Jim Puls on 2/3/14.
6+
// Licensed to Square, Inc. under one or more contributor license agreements.
7+
// See the LICENSE file distributed with this work for the terms under
8+
// which Square, Inc. licenses this file to you.
9+
10+
#import "CGTADetailViewController.h"
11+
#import "CGTATestAppColorList.h"
12+
13+
14+
@interface CGTADetailViewController ()
15+
16+
@property (nonatomic, strong) IBOutlet UIImageView *imageView;
17+
18+
@end
19+
20+
21+
@implementation CGTADetailViewController
22+
23+
- (void)setImage:(UIImage *)image;
24+
{
25+
_image = image;
26+
[self updateView];
27+
}
28+
29+
- (void)viewDidLoad;
30+
{
31+
[self updateView];
32+
33+
CAGradientLayer *layer = [CAGradientLayer layer];
34+
layer.startPoint = CGPointMake(0.5, 0.5);
35+
layer.endPoint = CGPointMake(0.5, 1.0);
36+
37+
layer.colors = @[(id)[UIColor whiteColor].CGColor, (id)[CGTATestAppColorList tealColor].CGColor];
38+
layer.frame = self.view.layer.bounds;
39+
[self.view.layer insertSublayer:layer atIndex:0];
40+
}
41+
42+
- (void)updateView;
43+
{
44+
self.imageView.image = self.image;
45+
}
46+
47+
@end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// CGTAImagesCatalog+RuntimeHackery.h
3+
// codegenutils
4+
//
5+
// Created by Jim Puls on 2/3/14.
6+
// Licensed to Square, Inc. under one or more contributor license agreements.
7+
// See the LICENSE file distributed with this work for the terms under
8+
// which Square, Inc. licenses this file to you.
9+
10+
#import "CGTAImagesCatalog.h"
11+
12+
@interface CGTAImagesCatalog (RuntimeHackery)
13+
14+
+ (NSArray *)allImages;
15+
16+
@end
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// CGTAImagesCatalog+RuntimeHackery.m
3+
// codegenutils
4+
//
5+
// Created by Jim Puls on 2/3/14.
6+
// Licensed to Square, Inc. under one or more contributor license agreements.
7+
// See the LICENSE file distributed with this work for the terms under
8+
// which Square, Inc. licenses this file to you.
9+
10+
#import "CGTAImagesCatalog+RuntimeHackery.h"
11+
12+
#import <objc/runtime.h>
13+
#import <objc/message.h>
14+
15+
16+
@implementation CGTAImagesCatalog (RuntimeHackery)
17+
18+
+ (NSArray *)allImages;
19+
{
20+
NSMutableArray *images = [NSMutableArray array];
21+
unsigned int count;
22+
Method *methods = class_copyMethodList(object_getClass(self), &count);
23+
for (unsigned int index = 0; index < count; index++) {
24+
if (sel_isEqual(method_getName(methods[index]), _cmd)) {
25+
continue;
26+
}
27+
id image = method_invoke(self, methods[index]);
28+
[images addObject:image];
29+
}
30+
free(methods);
31+
return images;
32+
}
33+
34+
@end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//
2+
// CGTAMasterViewController.h
3+
// CodeGenTestApp
4+
//
5+
// Created by Jim Puls on 2/3/14.
6+
// Licensed to Square, Inc. under one or more contributor license agreements.
7+
// See the LICENSE file distributed with this work for the terms under
8+
// which Square, Inc. licenses this file to you.
9+
10+
11+
@interface CGTAMasterViewController : UICollectionViewController
12+
@end
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
//
2+
// CGTAMasterViewController.m
3+
// CodeGenTestApp
4+
//
5+
// Created by Jim Puls on 2/3/14.
6+
// Licensed to Square, Inc. under one or more contributor license agreements.
7+
// See the LICENSE file distributed with this work for the terms under
8+
// which Square, Inc. licenses this file to you.
9+
10+
#import "CGTAMasterViewController.h"
11+
#import "CGTADetailViewController.h"
12+
#import "CGTAImagesCatalog+RuntimeHackery.h"
13+
#import "CGTAMainStoryboardIdentifiers.h"
14+
15+
16+
@interface CGTAFlagCollectionViewCell : UICollectionViewCell
17+
18+
@property (nonatomic, weak) IBOutlet UIImageView *imageView;
19+
20+
@end
21+
22+
23+
@interface CGTAMasterViewController ()
24+
25+
@property (nonatomic, weak) IBOutlet UISlider *cellSizeSlider;
26+
@property (nonatomic, strong) NSArray *flagImages;
27+
28+
@end
29+
30+
31+
@implementation CGTAMasterViewController
32+
33+
#pragma mark - NSObject
34+
35+
- (void)awakeFromNib;
36+
{
37+
[self sliderValueChanged:self.cellSizeSlider];
38+
}
39+
40+
#pragma mark - UIViewController
41+
42+
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender;
43+
{
44+
if ([segue.identifier isEqualToString:CGTAMainStoryboardTapOnFlagIdentifier]) {
45+
CGTADetailViewController *detailViewController = segue.destinationViewController;
46+
detailViewController.image = ((CGTAFlagCollectionViewCell *)sender).imageView.image;
47+
}
48+
}
49+
50+
#pragma mark - Private methods
51+
52+
- (IBAction)sliderValueChanged:(UISlider *)sender;
53+
{
54+
float newValue = sender.value;
55+
UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)self.collectionView.collectionViewLayout;
56+
layout.itemSize = CGSizeMake(newValue, newValue);
57+
}
58+
59+
- (NSArray *)flagImages;
60+
{
61+
NSArray *allFlagImages = nil;
62+
63+
// Initial version: full of strings that you have to type correctly!
64+
// Misspell any of these and your app will crash on trying to add `nil` to an array.
65+
allFlagImages = @[[UIImage imageNamed:@"USA"], [UIImage imageNamed:@"Canada"], [UIImage imageNamed:@"UK"], [UIImage imageNamed:@"Australia"]];
66+
67+
// New version: get the properly compiler-checked spelling from the image catalog.
68+
allFlagImages = @[[CGTAImagesCatalog usaImage], [CGTAImagesCatalog canadaImage], [CGTAImagesCatalog ukImage], [CGTAImagesCatalog australiaImage]];
69+
70+
// But really, why not use a little runtime hackery because we can?
71+
return [CGTAImagesCatalog allImages];
72+
}
73+
74+
#pragma mark - UICollectionViewDataSource
75+
76+
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView;
77+
{
78+
return 1;
79+
}
80+
81+
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section;
82+
{
83+
return self.flagImages.count;
84+
}
85+
86+
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath;
87+
{
88+
CGTAFlagCollectionViewCell *cell = (CGTAFlagCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:CGTAMainStoryboardImageCellIdentifier forIndexPath:indexPath];
89+
cell.imageView.image = self.flagImages[indexPath.item];
90+
return cell;
91+
}
92+
93+
@end
94+
95+
96+
@implementation CGTAFlagCollectionViewCell
97+
@end

0 commit comments

Comments
 (0)