Swiftpack.co - vGebs/SwiftUICam as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by vGebs.
vGebs/SwiftUICam 1.2.2
An AVFoundation based API that allows users to access the camera and its functions on their iOS devices with SwiftUI
⭐️ 28
🕓 3 years ago
iOS
.package(url: "https://github.com/vGebs/SwiftUICam.git", from: "1.2.2")

SwiftUICam

SwiftUICam is an AVFoundation based API that allows users to access the camera and its functions in a custom format on their iOS devices in SwiftUI with ease.

Feautures

It allows users to:

  1. Take pictures
  2. Take Videos
  3. Save pictures + videos to camera roll
  4. Toggle Between Cameras
  5. Toggle Flash
  6. Swipe to zoom

Acknowledgements

Sections of this API were derived from Awalz/SwiftyCam and KavSoft's tutorial.

Installation

This package is downloaded through Swift's Package Manager.

Usage

Using the Module

Object Initialization

import SwiftUICam

let camera = CameraWrapper()

Setting the view

  • To set the view, first create a structure that inhertits UIViewRepresentable.
  • This protocol states that you must implement two functions - MakeUIView & UpdateUIView.
  • MakeUIView - Sets the view (basically ViewDidLoad)
  • UpdateUIView - Updates after user input (viewDidChange)
  • To make these functions work with this framework, we will need to pass an instance of CameraWrapper and a view of type UIView.
  • We also want to declare the a UIView variable that will be used to specify the frame in which this view will sit.
  • Upon declaring these protocol functions and variables we can use the CameraWrapper to call the public preview setup functions as shown below.
import SwiftUICam

struct SwiftUICamPreview: UIViewRepresentable {
    
    @ObservedObject var camera: CameraWrapper
    var view: UIView

    func makeUIView(context: Context) ->  UIView {
        return camera.makeUIView(view)
    }

    func updateUIView(_ uiView: UIView, context: Context) { }
}

Further reading

For more information on how to setup/ use the interface, please reference Sources/SwiftUICam/SampleUsage

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

This package is under the MIT license

GitHub

link
Stars: 28
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics