{"id":13777545,"url":"https://github.com/pierreveron/SwiftUICam","last_synced_at":"2025-05-11T11:33:51.319Z","repository":{"id":41471341,"uuid":"251696341","full_name":"pierreveron/SwiftUICam","owner":"pierreveron","description":"A Snapchat Style Camera View to use with a SwiftUI interface","archived":true,"fork":false,"pushed_at":"2021-08-28T21:05:44.000Z","size":110,"stargazers_count":89,"open_issues_count":5,"forks_count":20,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-03T18:11:42.943Z","etag":null,"topics":["camera","snapchat","swift-package-manager","swiftui"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pierreveron.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-31T18:31:11.000Z","updated_at":"2024-07-30T22:25:01.000Z","dependencies_parsed_at":"2022-07-07T15:48:34.337Z","dependency_job_id":null,"html_url":"https://github.com/pierreveron/SwiftUICam","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierreveron%2FSwiftUICam","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierreveron%2FSwiftUICam/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierreveron%2FSwiftUICam/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierreveron%2FSwiftUICam/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pierreveron","download_url":"https://codeload.github.com/pierreveron/SwiftUICam/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225043159,"owners_count":17411938,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["camera","snapchat","swift-package-manager","swiftui"],"created_at":"2024-08-03T18:00:45.136Z","updated_at":"2024-11-17T13:30:55.050Z","avatar_url":"https://github.com/pierreveron.png","language":"Swift","funding_links":[],"categories":["Camera"],"sub_categories":["Content"],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/platform-iOS%2013%2B-blue.svg?style=flat\" alt=\"Platform: iOS 13.0+\"/\u003e\n    \u003ca href=\"https://developer.apple.com/swift\"\u003e\u003cimg src=\"https://img.shields.io/badge/language-swift%205.1-4BC51D.svg?style=flat\" alt=\"Language: Swift 5.1\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# SwiftUICam\n\nIf you want to have a custom camera using SwiftUI and not using the UIPickerController that will display the original iOS camera, but don’t have time to play with AVFoundation, this package is for you!\n\nSwiftUICam gives you a realtime full screen Snapchat-style view of the iPhone camera. Then, it is your job to built the interface you want and to connect it to the Camera View.\n\n## Features\n\n|                              | SwiftUICam        \n| ------------------------------------- | ---------------------\n| :sunglasses:                  | Snapchat-style media capture                              \n| :camera:  \t\t\t\t\t\t  | Image capture               \n| :movie_camera:  \t\t\t      | Video capture                               \n| :tada:                        | Front and rear camera support              \n| :flashlight:                  | Front and rear flash  \n| :sunny:                       | Retina flash support               \n| :mag_right:                   |  Supports manual zoom               \n| :lock:                        | Supports manual focus\n\n## Requirements\n\niOS 13.0+\n\n## Credits\n\nIt’s inspired by the project SwiftyCam made for UIKit: https://github.com/Awalz/SwiftyCam\n\n## License\n\nThis software is released under the MIT License, see LICENSE.txt.\n\n## Installation\n\n### Swift Package Manager:\n\nSwiftUICam is available through SPM. To install it, go to `File -\u003e Swift Packages -\u003e Add Package Dependency` \n\nAnd enter\n```\nhttps://github.com/pierreveron/SwiftUICam\n```\n\nAs the url.\n\n### Manual installation:\n\nSimply copy the contents of the Source folder into your project.\n\n## Usage\n\n### Prerequisites:\n\nAs of iOS 10, Apple requires the additon of the `NSCameraUsageDescription` and `NSMicrophoneUsageDescription` strings to the info.plist of your application. Example:\n\n```xml\n\u003ckey\u003eNSCameraUsageDescription\u003c/key\u003e\n\t\u003cstring\u003eTo Take Photos and Video\u003c/string\u003e\n\u003ckey\u003eNSMicrophoneUsageDescription\u003c/key\u003e\n\t\u003cstring\u003eTo Record Audio With Video\u003c/string\u003e\n```\n\n### Getting Started:\n\nIn your SwiftUI view simply add the CameraView, pass it the applicationName and add an @ObservedObject UserEvents that will be pass to the interface and the CameraViewRepresentable like this:\n\n```swift\nimport SwiftUI\nimport SwiftUICam\n\nstruct ContentView: View {\n    @ObservedObject events = UserEvents()\n    var body: some View {\n    \tZStack {\n              CameraView(events: events, applicationName: \"SwiftUICam\")\n\t      CameraInterfaceView(events: events)\n    \t}\n    }\n}\n\n```\n\n## Interface view\n\nMake your interface view conform to the CameraActions protocol and add the @ObservedObject UserEvents property.\nAdd gestures to your buttons that call the CameraActions functions and pass them the UserEvents property, simply as that.\n```swift\nimport SwiftUI\nimport SwiftUICam\n\nstruct CameraInterfaceView: View, CameraActions {    \n    @ObservedObject var events: UserEvents\n    \n    var body: some View {\n        VStack {\n            HStack {\n                rotateButton().onTapGesture {\n                    self.rotateCamera(events: events)\n                }\n                Spacer()\n                flashButton().onTapGesture {\n                    self.changeFlashMode(events: events)\n                }\n            }\n            Spacer()\n            captureButton().onTapGesture {\n                self.takePhoto(events: events)\n            }\n        }\n    }\n}\n```\n\n### CameraActions\n\nIt is the protocol that order the camera to take a picture or change the flash mode. List of the methods:\n\n```swift\nfunc takePhoto(events: UserEvents)\nfunc toggleVideoRecording(events: UserEvents)\nfunc rotateCamera(events: UserEvents)\nfunc changeFlashMode(events: UserEvents)\n```\n\nThe methods have a default definition to take make it easy to use.\n\n## Customize the CameraView\n\nYou can modify several properties of the CameraView on its initialization:\n```swift\ninit(events: UserEvents, applicationName: String, preferredStartingCameraType: AVCaptureDevice.DeviceType = .builtInWideAngleCamera, preferredStartingCameraPosition: AVCaptureDevice.Position = .back, focusImage: String? = nil, pinchToZoom: Bool = true, tapToFocus: Bool = true, doubleTapCameraSwitch: Bool = true)\n```\n- preferredStartingCameraType\n- preferredStartingCameraPosition\n- tapToFocus\n- focusImage\n- pinchToZoom\n- doubleTapCameraSwitch\n\n### Preferred Starting Options\n\nBy default, CameraView will launch to the back wide angle camera if it is available. This can be changed by changing the `preferredStartingCameraType` and the `preferredStartingCameraPosition`properties to your desired ones.\n\n### TapToFocus\n\nCameraView, by default, support tap to focus on the video preview. To disable this feature, pass to the `tapToFocus` property `false`.\n\n#### FocusImage\n\nWhen tapToFocus is enable, you can pass an UIImage that will be animate on the tap point.\n\n### PinchToZoom\n\nCameraView, by default, support pinchToZoom on the front and back camera. The gestures work similar to the default iOS app and will zoom to the maximum supported zoom level. To disable this feature, pass to the `pinchToZoom` property `false`.\n\n### DoubleTapCameraSwitch\n\nCameraView, by default, support double tap to switch camera. To disable this feature, pass to the `doubleTapCameraSwitch` property `false`.\n\n## What's next\n\n- Give more access to customization (max video duration, video quality, ...)\n- Add support for the device orientation\n- Add background audio support\n- Wait for Apple to release an update of SwiftUI to maybe make it simplier to use AVFoundation\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpierreveron%2FSwiftUICam","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpierreveron%2FSwiftUICam","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpierreveron%2FSwiftUICam/lists"}