MijickCamera/Sources/Public/Camera Settings/Public+CameraSettings+MApplicationDelegate.swift

54 lines
1.5 KiB
Swift
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// Public+CameraSettings+MApplicationDelegate.swift of MijickCamera
//
// Created by Tomasz Kurylik. Sending from Kraków!
// - Mail: tomasz.kurylik@mijick.com
// - GitHub: https://github.com/FulcrumOne
// - Medium: https://medium.com/@mijick
//
// Copyright ©2024 Mijick. All rights reserved.
import SwiftUI
/**
Locks the screen in portrait mode when the Camera Screen is active.
See ``MCamera/lockCameraInPortraitOrientation(_:)`` for more details.
- note: Blocks the rotation of the entire screen on which the **MCamera** is located.
## Usage
```swift
@main struct App_Main: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup(content: ContentView.init)
}
}
// MARK: App Delegate
class AppDelegate: NSObject, MApplicationDelegate {
static var orientationLock = UIInterfaceOrientationMask.all
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { AppDelegate.orientationLock }
}
// MARK: Content View
struct ContentView: View {
var body: some View {
MCamera()
.lockCameraInPortraitOrientation(AppDelegate.self)
// MUST BE CALLED!
.startSession()
}
}
```
*/
public protocol MApplicationDelegate: UIApplicationDelegate {
static var orientationLock: UIInterfaceOrientationMask { get set }
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask
}