-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e6161db
commit 71a7ba1
Showing
11 changed files
with
1,397 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
damus.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"pins" : [ | ||
{ | ||
"identity" : "gsplayer", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/wxxsw/GSPlayer", | ||
"state" : { | ||
"revision" : "aa6dad7943d52f5207f7fcc2ad3e4274583443b8", | ||
"version" : "0.2.26" | ||
} | ||
}, | ||
{ | ||
"identity" : "kingfisher", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/onevcat/Kingfisher", | ||
"state" : { | ||
"revision" : "415b1d97fb38bda1e5a6b2dde63354720832110b", | ||
"version" : "7.6.1" | ||
} | ||
}, | ||
{ | ||
"identity" : "secp256k1.swift", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/jb55/secp256k1.swift", | ||
"state" : { | ||
"revision" : "40b4b38b3b1c83f7088c76189a742870e0ca06a9" | ||
} | ||
}, | ||
{ | ||
"identity" : "swift-markdown-ui", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/damus-io/swift-markdown-ui", | ||
"state" : { | ||
"revision" : "76bb7971da7fbf429de1c84f1244adf657242fee" | ||
} | ||
} | ||
], | ||
"version" : 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
// | ||
// CameraModel.swift | ||
// damus | ||
// | ||
// Created by Suhail Saqan on 8/5/23. | ||
// | ||
|
||
import Foundation | ||
import AVFoundation | ||
import Combine | ||
|
||
final class CameraModel: ObservableObject { | ||
private let service = CameraService() | ||
|
||
@Published var showAlertError = false | ||
|
||
@Published var isFlashOn = false | ||
|
||
@Published var willCapturePhoto = false | ||
|
||
@Published var isCameraButtonDisabled = false | ||
|
||
@Published var isPhotoProcessing = false | ||
|
||
@Published var isRecording = false | ||
|
||
@Published var captureMode: CameraMediaType = .image | ||
|
||
@Published public var mediaItems: [MediaItem] = [] | ||
|
||
@Published var thumbnail: Thumbnail! | ||
|
||
var alertError: AlertError! | ||
|
||
var session: AVCaptureSession | ||
|
||
private var subscriptions = Set<AnyCancellable>() | ||
|
||
init() { | ||
self.session = service.session | ||
|
||
service.$shouldShowAlertView.sink { [weak self] (val) in | ||
self?.alertError = self?.service.alertError | ||
self?.showAlertError = val | ||
} | ||
.store(in: &self.subscriptions) | ||
|
||
service.$flashMode.sink { [weak self] (mode) in | ||
self?.isFlashOn = mode == .on | ||
} | ||
.store(in: &self.subscriptions) | ||
|
||
service.$willCapturePhoto.sink { [weak self] (val) in | ||
self?.willCapturePhoto = val | ||
} | ||
.store(in: &self.subscriptions) | ||
|
||
service.$isCameraButtonDisabled.sink { [weak self] (val) in | ||
self?.isCameraButtonDisabled = val | ||
} | ||
.store(in: &self.subscriptions) | ||
|
||
service.$isPhotoProcessing.sink { [weak self] (val) in | ||
self?.isPhotoProcessing = val | ||
} | ||
.store(in: &self.subscriptions) | ||
|
||
service.$isRecording.sink { [weak self] (val) in | ||
self?.isRecording = val | ||
} | ||
.store(in: &self.subscriptions) | ||
|
||
service.$captureMode.sink { [weak self] (mode) in | ||
self?.captureMode = mode | ||
} | ||
.store(in: &self.subscriptions) | ||
|
||
service.$mediaItems.sink { [weak self] (mode) in | ||
self?.mediaItems = mode | ||
} | ||
.store(in: &self.subscriptions) | ||
|
||
service.$thumbnail.sink { [weak self] (thumbnail) in | ||
guard let pic = thumbnail else { return } | ||
self?.thumbnail = pic | ||
} | ||
.store(in: &self.subscriptions) | ||
} | ||
|
||
func configure() { | ||
service.checkForPermissions() | ||
service.configure() | ||
} | ||
|
||
func stop() { | ||
service.stop() | ||
} | ||
|
||
func capturePhoto() { | ||
service.capturePhoto() | ||
} | ||
|
||
func startRecording() { | ||
service.startRecording() | ||
} | ||
|
||
func stopRecording() { | ||
service.stopRecording() | ||
} | ||
|
||
func flipCamera() { | ||
service.changeCamera() | ||
} | ||
|
||
func zoom(with factor: CGFloat) { | ||
service.set(zoom: factor) | ||
} | ||
|
||
func switchFlash() { | ||
service.flashMode = service.flashMode == .on ? .off : .on | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// CameraService+Extensions.swift | ||
// Campus | ||
// | ||
// Created by Rolando Rodriguez on 1/11/20. | ||
// Copyright © 2020 Rolando Rodriguez. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
import AVFoundation | ||
|
||
extension AVCaptureVideoOrientation { | ||
init?(deviceOrientation: UIDeviceOrientation) { | ||
switch deviceOrientation { | ||
case .portrait: self = .portrait | ||
case .portraitUpsideDown: self = .portraitUpsideDown | ||
case .landscapeLeft: self = .landscapeRight | ||
case .landscapeRight: self = .landscapeLeft | ||
default: return nil | ||
} | ||
} | ||
|
||
init?(interfaceOrientation: UIInterfaceOrientation) { | ||
switch interfaceOrientation { | ||
case .portrait: self = .portrait | ||
case .portraitUpsideDown: self = .portraitUpsideDown | ||
case .landscapeLeft: self = .landscapeLeft | ||
case .landscapeRight: self = .landscapeRight | ||
default: return nil | ||
} | ||
} | ||
} |
Oops, something went wrong.