This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
struct Message { | |
var id: String | |
var recieverId: String | |
var senderId: String | |
var content: String | |
} | |
protocol MessageRepository { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ModuleProvider | |
import UIKit | |
import Foundation | |
enum Module { | |
case none | |
case messages(YourConfigObject) | |
case feed | |
case profile | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: Checks for permisions, setup obeservers and starts running session | |
public func checkForPermissions() { | |
/* | |
Check the video authorization status. Video access is required and audio | |
access is optional. If the user denies audio access, CameraService won't | |
record audio during movie recording. | |
*/ | |
switch AVCaptureDevice.authorizationStatus(for: .video) { | |
case .authorized: | |
// The user has previously granted access to the camera. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CameraService { | |
typealias PhotoCaptureSessionID = String | |
// MARK: Observed Properties UI must react to | |
// 1. | |
@Published public var flashMode: AVCaptureDevice.FlashMode = .off | |
// 2. | |
@Published public var shouldShowAlertView = false | |
// 3. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
// MARK: Alert properties | |
public var alertError: AlertError = AlertError() | |
// MARK: Session Management Properties | |
// 9. The capture session. | |
public let session = AVCaptureSession() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct Photo: Identifiable, Equatable { | |
// The ID of the captured photo | |
public var id: String | |
// Data representation of the captured photo | |
public var originalData: Data | |
public init(id: String = UUID().uuidString, originalData: Data) { | |
self.id = id | |
self.originalData = originalData | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: Checks for user's permisions | |
public func checkForPermissions() { | |
switch AVCaptureDevice.authorizationStatus(for: .video) { | |
case .authorized: | |
// The user has previously granted access to the camera. | |
break | |
case .notDetermined: | |
/* | |
The user has not yet been presented with the option to grant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: Session Managment | |
// Call this on the session queue. | |
/// - Tag: ConfigureSession | |
private func configureSession() { | |
if setupResult != .success { | |
return | |
} | |
session.beginConfiguration() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// - Tag: Start capture session | |
public func start() { | |
// We use our capture session queue to ensure our UI runs smoothly on the main thread. | |
sessionQueue.async { | |
if !self.isSessionRunning && self.isConfigured { | |
switch self.setupResult { | |
case .success: | |
self.session.startRunning() | |
self.isSessionRunning = self.session.isRunning |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// - Tag: Stop capture session | |
public func stop(completion: (() -> ())? = nil) { | |
sessionQueue.async { | |
if self.isSessionRunning { | |
if self.setupResult == .success { | |
self.session.stopRunning() | |
self.isSessionRunning = self.session.isRunning | |
if !self.session.isRunning { |
OlderNewer