From 9f670298a194de70965208a1f2ce8f0c6db06765 Mon Sep 17 00:00:00 2001 From: Cagan Sevencan Date: Sun, 22 Mar 2020 15:00:42 -0700 Subject: [PATCH] Latest Update from Xcode --- Unload.xcodeproj/project.pbxproj | 4 + .../xcdebugger/Breakpoints_v2.xcbkptlist | 6 +- Unload/Base.lproj/Main.storyboard | 77 +++++++++++++++++- Unload/CameraViewController.swift | 80 +++++++++++++++++++ 4 files changed, 159 insertions(+), 8 deletions(-) create mode 100644 Unload/CameraViewController.swift diff --git a/Unload.xcodeproj/project.pbxproj b/Unload.xcodeproj/project.pbxproj index 2fa2572..143e3c7 100644 --- a/Unload.xcodeproj/project.pbxproj +++ b/Unload.xcodeproj/project.pbxproj @@ -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 */; }; @@ -56,6 +57,7 @@ 6F286BD22410B713001DBC08 /* UnloadUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnloadUITests.swift; sourceTree = ""; }; 6F286BD42410B713001DBC08 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 6F286BE02410B9EB001DBC08 /* LoginViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginViewController.swift; sourceTree = ""; }; + 6F2ACB412426E00600976AAD /* CameraViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CameraViewController.swift; sourceTree = ""; }; 6FEFBDA02426014400DC7C40 /* SceneDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 6FEFBDA22426B86900DC7C40 /* FeedViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedViewController.swift; sourceTree = ""; }; 825B19515C1FF63F072D7FA1 /* Pods_Unload.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Unload.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -126,6 +128,7 @@ 6F286BBE2410B713001DBC08 /* Info.plist */, 6F286BE02410B9EB001DBC08 /* LoginViewController.swift */, 6FEFBDA22426B86900DC7C40 /* FeedViewController.swift */, + 6F2ACB412426E00600976AAD /* CameraViewController.swift */, ); path = Unload; sourceTree = ""; @@ -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 */, diff --git a/Unload.xcworkspace/xcuserdata/caglasevencan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Unload.xcworkspace/xcuserdata/caglasevencan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 2ba369a..6acec30 100644 --- a/Unload.xcworkspace/xcuserdata/caglasevencan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/Unload.xcworkspace/xcuserdata/caglasevencan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -14,10 +14,8 @@ filePath = "Unload/CameraViewController.swift" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "54" - endingLineNumber = "54" - landmarkName = "CameraViewController" - landmarkType = "3"> + startingLineNumber = "81" + endingLineNumber = "81"> - + @@ -105,11 +105,76 @@ - + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -127,7 +192,11 @@ - + + + + + diff --git a/Unload/CameraViewController.swift b/Unload/CameraViewController.swift new file mode 100644 index 0000000..f35c93e --- /dev/null +++ b/Unload/CameraViewController.swift @@ -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. + } + */ + +}