Skip to content

Commit

Permalink
Latest Update from Xcode
Browse files Browse the repository at this point in the history
  • Loading branch information
cagansevencan committed Mar 22, 2020
1 parent e73148d commit 9f67029
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 8 deletions.
4 changes: 4 additions & 0 deletions Unload.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
6F286BC82410B713001DBC08 /* UnloadTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F286BC72410B713001DBC08 /* UnloadTests.swift */; };
6F286BD32410B713001DBC08 /* UnloadUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F286BD22410B713001DBC08 /* UnloadUITests.swift */; };
6F286BE12410B9EB001DBC08 /* LoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F286BE02410B9EB001DBC08 /* LoginViewController.swift */; };
6F2ACB422426E00600976AAD /* CameraViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F2ACB412426E00600976AAD /* CameraViewController.swift */; };
6FEFBDA12426014400DC7C40 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FEFBDA02426014400DC7C40 /* SceneDelegate.swift */; };
6FEFBDA32426B86900DC7C40 /* FeedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FEFBDA22426B86900DC7C40 /* FeedViewController.swift */; };
785BDFAF48A1A958610BE110 /* Pods_Unload.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 825B19515C1FF63F072D7FA1 /* Pods_Unload.framework */; };
Expand Down Expand Up @@ -56,6 +57,7 @@
6F286BD22410B713001DBC08 /* UnloadUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnloadUITests.swift; sourceTree = "<group>"; };
6F286BD42410B713001DBC08 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
6F286BE02410B9EB001DBC08 /* LoginViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginViewController.swift; sourceTree = "<group>"; };
6F2ACB412426E00600976AAD /* CameraViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CameraViewController.swift; sourceTree = "<group>"; };
6FEFBDA02426014400DC7C40 /* SceneDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
6FEFBDA22426B86900DC7C40 /* FeedViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedViewController.swift; sourceTree = "<group>"; };
825B19515C1FF63F072D7FA1 /* Pods_Unload.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Unload.framework; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -126,6 +128,7 @@
6F286BBE2410B713001DBC08 /* Info.plist */,
6F286BE02410B9EB001DBC08 /* LoginViewController.swift */,
6FEFBDA22426B86900DC7C40 /* FeedViewController.swift */,
6F2ACB412426E00600976AAD /* CameraViewController.swift */,
);
path = Unload;
sourceTree = "<group>";
Expand Down Expand Up @@ -404,6 +407,7 @@
buildActionMask = 2147483647;
files = (
6FEFBDA12426014400DC7C40 /* SceneDelegate.swift in Sources */,
6F2ACB422426E00600976AAD /* CameraViewController.swift in Sources */,
6F286BE12410B9EB001DBC08 /* LoginViewController.swift in Sources */,
6FEFBDA32426B86900DC7C40 /* FeedViewController.swift in Sources */,
6F286BB12410B712001DBC08 /* AppDelegate.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
filePath = "Unload/CameraViewController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "54"
endingLineNumber = "54"
landmarkName = "CameraViewController"
landmarkType = "3">
startingLineNumber = "81"
endingLineNumber = "81">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
Expand Down
77 changes: 73 additions & 4 deletions Unload/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Stz-nV-evj" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="78" y="-66"/>
<point key="canvasLocation" x="-332" y="-237"/>
</scene>
<!--Feed View Controller-->
<scene sceneID="KW0-c0-OkA">
Expand All @@ -105,11 +105,76 @@
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="FBZ-m6-dSG"/>
</view>
<navigationItem key="navigationItem" id="Asp-CD-Dv4"/>
<navigationItem key="navigationItem" id="Asp-CD-Dv4">
<barButtonItem key="rightBarButtonItem" title="Pic" image="livephoto" catalog="system" id="Ibx-vT-cXt">
<connections>
<segue destination="vWV-6G-Spx" kind="presentation" id="4sc-1J-HD7"/>
</connections>
</barButtonItem>
</navigationItem>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="oiE-wc-gUP" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1578" y="-58"/>
<point key="canvasLocation" x="1259" y="-228"/>
</scene>
<!--Camera View Controller-->
<scene sceneID="kN5-mn-UKz">
<objects>
<viewController id="vWV-6G-Spx" customClass="CameraViewController" customModule="Unload" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="4HY-ZS-NV8">
<rect key="frame" x="0.0" y="0.0" width="414" height="842"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="photo.fill" catalog="system" translatesAutoresizingMaskIntoConstraints="NO" id="x87-J0-iT8">
<rect key="frame" x="20" y="20" width="374" height="309"/>
<gestureRecognizers/>
<constraints>
<constraint firstAttribute="height" constant="311.5" id="ud2-lX-5BZ"/>
</constraints>
<connections>
<outletCollection property="gestureRecognizers" destination="KLy-Bz-cLL" appends="YES" id="SFa-Da-aqW"/>
</connections>
</imageView>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="cbo-mx-QLV">
<rect key="frame" x="20" y="338" width="374" height="34"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="JBZ-7b-79Y">
<rect key="frame" x="20" y="406" width="374" height="30"/>
<state key="normal" title="SUBMIT"/>
<connections>
<action selector="onSubmitButton:" destination="vWV-6G-Spx" eventType="touchUpInside" id="aEy-a6-Md4"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstItem="JBZ-7b-79Y" firstAttribute="leading" secondItem="Gmp-Yz-jH4" secondAttribute="leading" constant="20" id="3BY-zL-ttK"/>
<constraint firstItem="JBZ-7b-79Y" firstAttribute="top" secondItem="cbo-mx-QLV" secondAttribute="bottom" constant="34" id="LpE-0c-CqP"/>
<constraint firstItem="x87-J0-iT8" firstAttribute="leading" secondItem="cbo-mx-QLV" secondAttribute="leading" id="Rv5-qY-xGr"/>
<constraint firstItem="Gmp-Yz-jH4" firstAttribute="trailing" secondItem="JBZ-7b-79Y" secondAttribute="trailing" constant="20" id="UhQ-ED-L1V"/>
<constraint firstItem="cbo-mx-QLV" firstAttribute="top" secondItem="x87-J0-iT8" secondAttribute="bottom" constant="7.5" id="bBZ-kK-SwF"/>
<constraint firstItem="cbo-mx-QLV" firstAttribute="leading" secondItem="Gmp-Yz-jH4" secondAttribute="leading" constant="20" id="fPl-0J-1Ye"/>
<constraint firstItem="x87-J0-iT8" firstAttribute="top" secondItem="Gmp-Yz-jH4" secondAttribute="top" constant="19" id="oYk-Tw-abi"/>
<constraint firstItem="Gmp-Yz-jH4" firstAttribute="trailing" secondItem="cbo-mx-QLV" secondAttribute="trailing" constant="20" id="r0a-8d-Sre"/>
<constraint firstItem="x87-J0-iT8" firstAttribute="trailing" secondItem="cbo-mx-QLV" secondAttribute="trailing" id="ttI-eW-owS"/>
</constraints>
<viewLayoutGuide key="safeArea" id="Gmp-Yz-jH4"/>
</view>
<connections>
<outlet property="commentField" destination="cbo-mx-QLV" id="Z9U-MQ-Vru"/>
<outlet property="imageView" destination="x87-J0-iT8" id="Ts4-Wh-rKO"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="mIo-Jz-ka1" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
<tapGestureRecognizer id="KLy-Bz-cLL">
<connections>
<action selector="onCameraButton:" destination="vWV-6G-Spx" id="k63-Jq-fiV"/>
</connections>
</tapGestureRecognizer>
</objects>
<point key="canvasLocation" x="2209" y="-211"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="wii-To-GLP">
Expand All @@ -127,7 +192,11 @@
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="xGC-k4-Llf" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="839" y="-66"/>
<point key="canvasLocation" x="486" y="-237"/>
</scene>
</scenes>
<resources>
<image name="livephoto" catalog="system" width="64" height="60"/>
<image name="photo.fill" catalog="system" width="64" height="46"/>
</resources>
</document>
80 changes: 80 additions & 0 deletions Unload/CameraViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
//
// CameraViewController.swift
// Unload
//
// Created by Cagan Sevencan on 3/21/20.
// Copyright © 2020 Cagan Sevencan. All rights reserved.
//

import UIKit
import AlamofireImage
import Parse
class CameraViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {

@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var commentField: UITextField!

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}

@IBAction func onSubmitButton(_ sender: Any) {
let item = PFObject(className: "Items")

item["description"] = commentField.text!
item["user"] = PFUser.current()!

let imageData = imageView.image!.pngData()
//save in a seperate table for pics
//Create a new Parse file
let file = PFFileObject(data: imageData!) //Binary Object
item["image"] = file //this column will have the URL to file

item.saveInBackground { (success, error) in
if success{
self.dismiss(animated: true, completion: nil)
print("saved")
}else{
print("error!")
}
}
}

//When we tap the image we want this method to run
@IBAction func onCameraButton(_ sender: Any) {
let picker = UIImagePickerController() // Special built in view controller
picker.delegate = self // when you are done taking a pic lmk what they took, call me back on a func that has the pic
picker.allowsEditing = true //Presents second screen for editing

if UIImagePickerController.isSourceTypeAvailable(.camera){//swift enum - it figures what enum u expecting
picker.sourceType = .camera
}else{
picker.sourceType = .photoLibrary
}
present(picker, animated: true, completion: nil)
}
//Will hand you back a dictionary that has the image
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info:
[UIImagePickerController.InfoKey : Any]) {
let image = info[.editedImage] as! UIImage // we take the image out and cast it coming out of dict.

//once we have the image we have to resize it for it upload quickly - also Heroku has a limit
let size = CGSize(width: 300, height: 300)
let scaledImage = image.af_imageScaled(to: size)
imageView.image = scaledImage

dismiss(animated: true, completion: nil) //dismiss camera view
}

/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/

}

0 comments on commit 9f67029

Please sign in to comment.