From 95ee84086a326f66f9fdce8395e5367e4e560f52 Mon Sep 17 00:00:00 2001 From: Rodolfo Ortiz Date: Sat, 1 Feb 2020 19:39:53 -0600 Subject: [PATCH 1/4] Prueba --- fakestagram.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fakestagram.xcodeproj/project.pbxproj b/fakestagram.xcodeproj/project.pbxproj index fd88dc7..d8bc53f 100644 --- a/fakestagram.xcodeproj/project.pbxproj +++ b/fakestagram.xcodeproj/project.pbxproj @@ -689,7 +689,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = D3XL2U7DQC; + DEVELOPMENT_TEAM = R83P3CD95H; INFOPLIST_FILE = fakestagram/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -711,7 +711,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = D3XL2U7DQC; + DEVELOPMENT_TEAM = R83P3CD95H; INFOPLIST_FILE = fakestagram/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", From ad199757910f06c2b2c89815acbb90c1dc7bda8f Mon Sep 17 00:00:00 2001 From: Rodolfo Ortiz Date: Sat, 1 Feb 2020 19:48:47 -0600 Subject: [PATCH 2/4] Camera Fix --- Podfile | 11 +++++++---- Podfile.lock | 4 ++-- .../ViewControllers/CameraViewController.swift | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Podfile b/Podfile index 77cfa72..f962121 100644 --- a/Podfile +++ b/Podfile @@ -1,14 +1,17 @@ # Uncomment the next line to define a global platform for your project -platform :ios, '13.0' +# platform :ios, '9.0' target 'fakestagram' do - # Comment the next line if you don't want to use dynamic frameworks + # Comment the next line if you're not using Swift and don't want to use dynamic frameworks use_frameworks! + # Pods for fakestagram - pod 'SAMKeychain' +pod 'SAMKeychain' target 'fakestagramTests' do inherit! :search_paths pod 'DVR' + # Pods for testing end -end + +end \ No newline at end of file diff --git a/Podfile.lock b/Podfile.lock index 12505e8..b78c244 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -15,6 +15,6 @@ SPEC CHECKSUMS: DVR: 062c287b9dc613a84120e44640176e4ef3ecf943 SAMKeychain: 483e1c9f32984d50ca961e26818a534283b4cd5c -PODFILE CHECKSUM: 02c21c317ba9be4fdecdfff242f3fa20e9b269bd +PODFILE CHECKSUM: 5f20627b56a905f9a7ea5dc594a4450b05e9922f -COCOAPODS: 1.8.3 +COCOAPODS: 1.8.4 diff --git a/fakestagram/ViewControllers/CameraViewController.swift b/fakestagram/ViewControllers/CameraViewController.swift index a7996c7..8ecb278 100644 --- a/fakestagram/ViewControllers/CameraViewController.swift +++ b/fakestagram/ViewControllers/CameraViewController.swift @@ -99,7 +99,7 @@ class CameraViewController: UIViewController { func setupCaptureSession() { session.beginConfiguration() - let device = AVCaptureDevice.default(.builtInDualCamera, + let device = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back)! guard let videoDeviceInput = try? AVCaptureDeviceInput(device: device), session.canAddInput(videoDeviceInput) else { return } From 94b35730949ad534fbc485317d2a0a56fb1c65e6 Mon Sep 17 00:00:00 2001 From: Rodolfo Ortiz Date: Mon, 3 Feb 2020 18:59:02 -0600 Subject: [PATCH 3/4] =?UTF-8?q?Logo=20bot=C3=B3n=20FlipCam?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fakestagram/Base.lproj/Main.storyboard | 27 +++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/fakestagram/Base.lproj/Main.storyboard b/fakestagram/Base.lproj/Main.storyboard index 469596b..5b9b194 100644 --- a/fakestagram/Base.lproj/Main.storyboard +++ b/fakestagram/Base.lproj/Main.storyboard @@ -2,7 +2,7 @@ - + @@ -67,19 +67,35 @@ + - - - + + + + + + @@ -140,6 +156,7 @@ + From 066331fd076e73b8c19f46583f74578bd349e472 Mon Sep 17 00:00:00 2001 From: Rodolfo Ortiz Date: Mon, 3 Feb 2020 21:59:35 -0600 Subject: [PATCH 4/4] Camera Flip --- fakestagram/Base.lproj/Main.storyboard | 66 ++++++++-------- .../CameraViewController.swift | 76 +++++++++++++++---- 2 files changed, 93 insertions(+), 49 deletions(-) diff --git a/fakestagram/Base.lproj/Main.storyboard b/fakestagram/Base.lproj/Main.storyboard index 5b9b194..1cc815f 100644 --- a/fakestagram/Base.lproj/Main.storyboard +++ b/fakestagram/Base.lproj/Main.storyboard @@ -63,48 +63,44 @@ + - - - - - + + + - - - - + + + + + + + + + + diff --git a/fakestagram/ViewControllers/CameraViewController.swift b/fakestagram/ViewControllers/CameraViewController.swift index 8ecb278..709fbf3 100644 --- a/fakestagram/ViewControllers/CameraViewController.swift +++ b/fakestagram/ViewControllers/CameraViewController.swift @@ -41,16 +41,24 @@ class CameraViewController: UIViewController { settings.flashMode = .auto photoOutput.capturePhoto(with: settings, delegate: self) } - - /* - // 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. - } - */ + + + @IBAction func switchCamera(_ sender: UIButton) { + guard let currentCameraInput: AVCaptureInput = session.inputs.first else { + return + } + + if let input = currentCameraInput as? AVCaptureDeviceInput { + if input.device.position == .back { + switchToFrontCamera() + } + + if input.device.position == .front { + switchToBackCamera() + } + } + } + // MARK: - CoreLocation methods let locationManager = CLLocationManager() @@ -71,6 +79,7 @@ class CameraViewController: UIViewController { // MARK: - AVFoundation methods @IBOutlet weak var previewView: PreviewView! + func enableCameraAccess() { switch AVCaptureDevice.authorizationStatus(for: .video) { case .authorized: @@ -94,15 +103,18 @@ class CameraViewController: UIViewController { } } - let session = AVCaptureSession() + var session = AVCaptureSession() let photoOutput = AVCapturePhotoOutput() + var videoPreviewLeyer = AVCaptureVideoPreviewLayer() + + var frontCamera = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .front) + var backCamera = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back) func setupCaptureSession() { session.beginConfiguration() - let device = AVCaptureDevice.default(.builtInWideAngleCamera, - for: .video, position: .back)! + let device = backCamera! guard let videoDeviceInput = try? AVCaptureDeviceInput(device: device), - session.canAddInput(videoDeviceInput) else { return } + session.canAddInput(videoDeviceInput) else { return } session.addInput(videoDeviceInput) guard session.canAddOutput(photoOutput) else { return } @@ -114,6 +126,42 @@ class CameraViewController: UIViewController { session.startRunning() } + + func switchToFrontCamera () { + if frontCamera?.isConnected == true { + session.stopRunning() + let captureDevice = frontCamera + do { + let input = try AVCaptureDeviceInput(device: captureDevice!) + session = AVCaptureSession() + session.addInput(input) + videoPreviewLeyer = AVCaptureVideoPreviewLayer(session: session) + videoPreviewLeyer.frame = previewView.layer.bounds + previewView.layer.addSublayer(videoPreviewLeyer) + session.startRunning() + } catch { + print("Error") + } + } + } + + func switchToBackCamera () { + if frontCamera?.isConnected == true { + session.stopRunning() + let captureDevice = backCamera + do { + let input = try AVCaptureDeviceInput(device: captureDevice!) + session = AVCaptureSession() + session.addInput(input) + videoPreviewLeyer = AVCaptureVideoPreviewLayer(session: session) + videoPreviewLeyer.frame = previewView.layer.bounds + previewView.layer.addSublayer(videoPreviewLeyer) + session.startRunning() + } catch { + print("Error") + } + } + } }