-
-
Notifications
You must be signed in to change notification settings - Fork 36
Customizing MCamera Screens
Dzisiejsze pokolenie ma mocne głowy i zimne serca.
MCamera
is a view object that contains three screens that are displayed in relation to the state of the camera:
-
ErrorScreen
, which is shown when the user denies any of the required permissions, -
CapturedMediaScreen
, which is presented when the user captures either an image or video (can be disabled), -
CameraScreen
, which contains all of the camera controls that the user can interact with to adjust and capture images or video.
On this page, we are going to learn how to create your own `MCamera' screen(s) and what methods you can use to make this process as easy as possible for you. For this reason, this page is divided into three separate sections that cover this topic and provide a code example to help you easily get started with customizing your own camera screens.
By definition, it's a screen that displays an error message when one or more camera permissions are denied by the user.
The default screen can be replaced by creating a structure conforming to MCameraErrorScreen
and setting it as the error screen during MCamera
initialization.
- Create a struct conforming to
MCameraErrorScreen
struct CustomCameraErrorScreen: MCameraErrorScreen { let error: MCameraError let closeMCameraAction: () -> () var body: some View { Button(action: openAppSettings) { Text("Open Settings") } } }
- Pass the newly created screen as an argument during
MCamera
initialization
struct ContentView: View { var body: some View { MCamera() .setErrorScreen(CustomCameraErrorScreen.init) // MUST BE CALLED! .startSession() } }
-
openAppSettings()
- A method that when triggered, the user will open the application settings.
In a nutshell, it's a screen that displays the captured media. The default screen can be replaced by creating a structure conforming to MCapturedMediaScreen
and setting it as the captured media screen during MCamera
initialization. It's also possible to disable this screen by calling the `setCapturedMediaScreen' method with a nil value.
- Create a struct conforming to
MCapturedMediaScreen