Skip to content

Commit afda39b

Browse files
committed
Converted to Swift 2.0
Added removed Spring source files and added the library as a cocoapod. Added a check in the login view to show an alert if either the username or password are blank.
1 parent 1372e3e commit afda39b

File tree

118 files changed

+2231
-1385
lines changed

Some content is hidden

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

118 files changed

+2231
-1385
lines changed

Dindr.xcodeproj/project.pbxproj

Lines changed: 12 additions & 131 deletions
Large diffs are not rendered by default.

Dindr/AppDelegate.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
import UIKit
10+
import Parse
1011

1112
@UIApplicationMain
1213
class AppDelegate: UIResponder, UIApplicationDelegate {

Dindr/Base.lproj/Main.storyboard

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="z1v-CH-54s">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9059" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="z1v-CH-54s">
33
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
4+
<deployment identifier="iOS"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
56
</dependencies>
67
<scenes>
78
<!--LoginVC-->
@@ -18,16 +19,19 @@
1819
<subviews>
1920
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="username" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="2oh-p6-PuV">
2021
<rect key="frame" x="16" y="180" width="343" height="30"/>
22+
<animations/>
2123
<fontDescription key="fontDescription" name="AvenirNext-Regular" family="Avenir Next" pointSize="14"/>
2224
<textInputTraits key="textInputTraits"/>
2325
</textField>
2426
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="password" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="tox-4I-8kg">
2527
<rect key="frame" x="16" y="218" width="343" height="30"/>
28+
<animations/>
2629
<fontDescription key="fontDescription" name="AvenirNext-Regular" family="Avenir Next" pointSize="14"/>
2730
<textInputTraits key="textInputTraits" secureTextEntry="YES"/>
2831
</textField>
2932
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="nbm-8q-3DF" customClass="DesignableButton" customModule="Dindr" customModuleProvider="target">
3033
<rect key="frame" x="16" y="302" width="343" height="50"/>
34+
<animations/>
3135
<color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="calibratedRGB"/>
3236
<fontDescription key="fontDescription" name="AvenirNext-Regular" family="Avenir Next" pointSize="16"/>
3337
<state key="normal" title="Log In">
@@ -44,6 +48,7 @@
4448
</connections>
4549
</button>
4650
</subviews>
51+
<animations/>
4752
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
4853
<gestureRecognizers/>
4954
<connections>
@@ -75,82 +80,100 @@
7580
<viewControllerLayoutGuide type="bottom" id="pHy-p3-QVK"/>
7681
</layoutGuides>
7782
<view key="view" contentMode="scaleToFill" id="Pbi-Sg-xEg">
78-
<rect key="frame" x="0.0" y="0.0" width="375" height="603"/>
83+
<rect key="frame" x="0.0" y="64" width="375" height="603"/>
7984
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
8085
<subviews>
8186
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="resticon2" translatesAutoresizingMaskIntoConstraints="NO" id="ERi-p4-okV">
8287
<rect key="frame" x="93" y="558" width="94" height="90"/>
88+
<animations/>
8389
</imageView>
8490
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="resticon2" translatesAutoresizingMaskIntoConstraints="NO" id="iMh-t5-8fA">
8591
<rect key="frame" x="188" y="558" width="94" height="90"/>
92+
<animations/>
8693
</imageView>
8794
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="resticon2" translatesAutoresizingMaskIntoConstraints="NO" id="yTR-bl-OYd">
8895
<rect key="frame" x="281" y="558" width="94" height="90"/>
96+
<animations/>
8997
</imageView>
9098
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="resticon" translatesAutoresizingMaskIntoConstraints="NO" id="Jr1-xl-FsO">
9199
<rect key="frame" x="0.0" y="469" width="94" height="90"/>
100+
<animations/>
92101
</imageView>
93102
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="resticon" translatesAutoresizingMaskIntoConstraints="NO" id="AdT-6H-TVt">
94103
<rect key="frame" x="93" y="469" width="94" height="90"/>
104+
<animations/>
95105
</imageView>
96106
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="resticon" translatesAutoresizingMaskIntoConstraints="NO" id="BNh-tv-mhC">
97107
<rect key="frame" x="188" y="469" width="94" height="90"/>
108+
<animations/>
98109
</imageView>
99110
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="resticon" translatesAutoresizingMaskIntoConstraints="NO" id="xMx-G0-ipX">
100111
<rect key="frame" x="281" y="469" width="94" height="90"/>
112+
<animations/>
101113
</imageView>
102114
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="resticon2" translatesAutoresizingMaskIntoConstraints="NO" id="Zly-fu-FBT">
103115
<rect key="frame" x="0.0" y="558" width="94" height="90"/>
116+
<animations/>
104117
</imageView>
105118
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Tap Top Row Images to Upload" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bbc-Ap-tDo">
106119
<rect key="frame" x="88" y="440" width="199" height="21"/>
120+
<animations/>
107121
<fontDescription key="fontDescription" name="AvenirNext-Regular" family="Avenir Next" pointSize="14"/>
108122
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
109123
<nil key="highlightedColor"/>
110124
</label>
111125
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="moh-ix-DDU" userLabel="buttonimage1">
112126
<rect key="frame" x="0.0" y="469" width="94" height="90"/>
127+
<animations/>
113128
<state key="normal">
114129
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
115130
</state>
116131
</button>
117132
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="70C-fs-7Pe" userLabel="buttonimage2">
118133
<rect key="frame" x="93" y="469" width="94" height="90"/>
134+
<animations/>
119135
<state key="normal">
120136
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
121137
</state>
122138
</button>
123139
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="EDb-bh-8Yx" userLabel="buttonimage3">
124140
<rect key="frame" x="188" y="469" width="94" height="90"/>
141+
<animations/>
125142
<state key="normal">
126143
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
127144
</state>
128145
</button>
129146
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="WtO-nV-BJc" userLabel="buttonimage4">
130147
<rect key="frame" x="281" y="469" width="94" height="90"/>
148+
<animations/>
131149
<state key="normal">
132150
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
133151
</state>
134152
</button>
135153
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="statbackground" translatesAutoresizingMaskIntoConstraints="NO" id="iSN-4O-U55">
136154
<rect key="frame" x="3" y="53" width="180" height="170"/>
155+
<animations/>
137156
</imageView>
138157
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="J9J-xT-Ova">
139158
<rect key="frame" x="191" y="53" width="180" height="170"/>
159+
<animations/>
140160
</imageView>
141161
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="30" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MBy-4E-IX6">
142162
<rect key="frame" x="52" y="88" width="87" height="69"/>
163+
<animations/>
143164
<fontDescription key="fontDescription" name="AvenirNext-DemiBold" family="Avenir Next" pointSize="50"/>
144165
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
145166
<nil key="highlightedColor"/>
146167
</label>
147168
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Dishes swiped by Active Users" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="I4v-1c-KIB">
148169
<rect key="frame" x="8" y="165" width="175" height="58"/>
170+
<animations/>
149171
<fontDescription key="fontDescription" name="AvenirNext-Regular" family="Avenir Next" pointSize="20"/>
150172
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
151173
<nil key="highlightedColor"/>
152174
</label>
153175
</subviews>
176+
<animations/>
154177
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
155178
</view>
156179
<navigationItem key="navigationItem" title="Dindr" id="NLS-Mq-WRb"/>
@@ -182,6 +205,7 @@
182205
<navigationBar key="navigationBar" contentMode="scaleToFill" translucent="NO" id="cnp-gB-TBp">
183206
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
184207
<autoresizingMask key="autoresizingMask"/>
208+
<animations/>
185209
<color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="calibratedRGB"/>
186210
<color key="barTintColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="calibratedRGB"/>
187211
<textAttributes key="titleTextAttributes">
@@ -191,6 +215,7 @@
191215
<nil name="viewControllers"/>
192216
<toolbar key="toolbar" opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="T5z-Nf-2fD">
193217
<autoresizingMask key="autoresizingMask"/>
218+
<animations/>
194219
</toolbar>
195220
<connections>
196221
<segue destination="z1v-CH-54s" kind="relationship" relationship="rootViewController" id="6JU-YM-DX4"/>

Dindr/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<key>CFBundleExecutable</key>
88
<string>$(EXECUTABLE_NAME)</string>
99
<key>CFBundleIdentifier</key>
10-
<string>io.ImagineME.$(PRODUCT_NAME:rfc1034identifier)</string>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
1111
<key>CFBundleInfoDictionaryVersion</key>
1212
<string>6.0</string>
1313
<key>CFBundleName</key>

Dindr/LoginVC.swift

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
//
88

99
import UIKit
10+
import Spring
11+
import Parse
1012

1113
class LoginVC: UIViewController, UITextFieldDelegate, UIAlertViewDelegate {
1214

@@ -28,26 +30,34 @@ class LoginVC: UIViewController, UITextFieldDelegate, UIAlertViewDelegate {
2830
}
2931

3032
@IBAction func loginButtonPressed(sender: AnyObject) {
31-
println("Login Button Pressed")
33+
print("Login Button Pressed")
3234
loginButton.animation = "pop"
3335
loginButton.animate()
3436

35-
var username = usernameTextField.text
36-
var password = passwordTextField.text
37+
guard let username = usernameTextField.text, password = passwordTextField.text else {
38+
// TODO: add alert
39+
showAlertWithMessage("Please fill in both username and password fields")
40+
return
41+
}
3742

3843
passwordTextField.resignFirstResponder()
3944

4045
view.showHUD(view)
4146

42-
PFUser.logInWithUsernameInBackground(usernameTextField.text, password:passwordTextField.text) {
47+
PFUser.logInWithUsernameInBackground(username, password:password) {
4348
(user, error) -> Void in
4449

4550
if user != nil { // Login successfull
4651
self.dismissViewControllerAnimated(true, completion: nil)
4752
hudView.removeFromSuperview()
48-
println("Successful Login")
53+
print("Successful Login")
54+
55+
} else {
4956

50-
} else { // Login failed. Try again or SignUp
57+
// Login failed. Try again or SignUp
58+
// TODO: sign up doesn't seem to go anywhere
59+
// TODO: also UIAlertView is deprecated, this needs to be changed to UIAlertController
60+
// TODO: see below for an example
5161
let alert = UIAlertView(title: "Dindr",
5262
message: "\(error!.localizedDescription)",
5363
delegate: self,
@@ -61,7 +71,15 @@ class LoginVC: UIViewController, UITextFieldDelegate, UIAlertViewDelegate {
6171

6272
}
6373

64-
74+
func showAlertWithMessage(message: String) {
75+
let alert = UIAlertController(title: nil, message: message, preferredStyle: .Alert)
76+
77+
let okAction = UIAlertAction(title: "OK", style: .Default, handler: nil)
78+
79+
alert.addAction(okAction)
80+
81+
self.presentViewController(alert, animated: true, completion: nil)
82+
}
6583

6684

6785

Dindr/RestaurantDataViewController.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
import UIKit
10+
import Parse
1011

1112
class RestaurantDataViewController: UIViewController, UIAlertViewDelegate,
1213
UINavigationControllerDelegate,
@@ -47,10 +48,10 @@ UIImagePickerControllerDelegate {
4748

4849
// BUTTON FOR IMAGES
4950
func buttImageTapped(sender: UIButton) {
50-
var button = sender as UIButton
51+
let button = sender as UIButton
5152
buttTAG = button.tag
5253

53-
var alert = UIAlertView(title: "Dindr",
54+
let alert = UIAlertView(title: "Dindr",
5455
message: "Add a Photo",
5556
delegate: self,
5657
cancelButtonTitle: "Cancel",
@@ -68,7 +69,7 @@ UIImagePickerControllerDelegate {
6869
// OPEN DEVICE'S CAMERA
6970
if alertView.buttonTitleAtIndex(buttonIndex) == "Take a picture" {
7071
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera) {
71-
var imagePicker = UIImagePickerController()
72+
let imagePicker = UIImagePickerController()
7273
imagePicker.delegate = self
7374
imagePicker.sourceType = UIImagePickerControllerSourceType.Camera;
7475
imagePicker.allowsEditing = false
@@ -79,7 +80,7 @@ UIImagePickerControllerDelegate {
7980
// PICK A PHOTO FROM LIBRARY
8081
} else if alertView.buttonTitleAtIndex(buttonIndex) == "Choose from Library" {
8182
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.PhotoLibrary) {
82-
var imagePicker = UIImagePickerController()
83+
let imagePicker = UIImagePickerController()
8384
imagePicker.delegate = self
8485
imagePicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary;
8586
imagePicker.allowsEditing = false

0 commit comments

Comments
 (0)