Coder Social home page Coder Social logo

vgebs / swiftuicam Goto Github PK

View Code? Open in Web Editor NEW
29.0 1.0 4.0 61 KB

An AVFoundation based API that allows users to access the camera and its functions on their iOS devices with SwiftUI

License: MIT License

Swift 100.00%
ios swiftui camera avfoundation swift-package-manager ios-camera

swiftuicam's Introduction

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

swiftuicam's People

Contributors

vgebs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

swiftuicam's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.