-
-
Notifications
You must be signed in to change notification settings - Fork 37
Integration
Gdy cię mają wieszać, poproś o szklankę wody. Nigdy nie wiadomo, co się wydarzy, zanim przyniosą.
This page is an introduction to the integration of MijickCamera
into your application. All code examples presented in this wiki are based on iOS and omit trivial things that might distract you from the core of the topic. However, it should not be too difficult to adapt this code into a working version.
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.
We shall discuss all the methods and ways of customizing MCamera
in the following pages (you can find links to them at the bottom of this page), but for now I'd like to introduce you to the simplest way of implementing MCamera
in your application.
- The first step is to place the
MCamera
in the contents of the view (or subview)
struct ContentView: View { var body: some View { (...) MCamera() (...) } }
- Now we'll declare the actions that will be called after user captures video and image
struct ContentView: View { var body: some View { (...) MCamera() .onImageCaptured { image, controller in saveImageInGallery(image) controller.reopenCameraScreen() } .onVideoCaptured { videoURL, controller in saveVideoInGallery(videoURL) controller.reopenCameraScreen() } (...) } }
- The only thing left to do is to start the camera session
struct ContentView: View { var body: some View { (...) MCamera() .onImageCaptured { image, controller in saveImageInGallery(image) controller.reopenCameraScreen() } .onVideoCaptured { videoURL, controller in saveVideoInGallery(videoURL) controller.reopenCameraScreen() } .startSession() (...) } }
Et voilà! We have just finished integrating MCamera
into your application! In the following pages I'll show you how to customize your camera view with MijickCamera
.