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
extension CameraViewController : UIViewControllerRepresentable{ | |
public typealias UIViewControllerType = CameraViewController | |
public func makeUIViewController(context: UIViewControllerRepresentableContext<CameraViewController>) -> CameraViewController { | |
return CameraViewController() | |
} | |
public func updateUIViewController(_ uiViewController: CameraViewController, context: UIViewControllerRepresentableContext<CameraViewController>) { | |
} | |
} |
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
override func viewDidLoad() { | |
previewView = UIView(frame: CGRect(x:0, y:0, width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.height)) | |
previewView.contentMode = UIView.ContentMode.scaleAspectFit | |
view.addSubview(previewView) | |
cameraController.prepare {(error) in | |
if let error = error { | |
print(error) | |
} |
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
func displayPreview(on view: UIView) throws { | |
guard let captureSession = self.captureSession, captureSession.isRunning else { throw CameraControllerError.captureSessionIsMissing } | |
self.previewLayer = AVCaptureVideoPreviewLayer(session: captureSession) | |
self.previewLayer?.videoGravity = AVLayerVideoGravity.resizeAspectFill | |
self.previewLayer?.connection?.videoOrientation = .portrait | |
view.layer.insertSublayer(self.previewLayer!, at: 0) | |
self.previewLayer?.frame = view.frame | |
} |
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
func prepare(completionHandler: @escaping (Error?) -> Void){ | |
func createCaptureSession(){ | |
self.captureSession = AVCaptureSession() | |
} | |
func configureCaptureDevices() throws { | |
let camera = AVCaptureDevice.default(.builtInWideAngleCamera, for: AVMediaType.video, position: .front) | |
self.frontCamera = camera | |
try camera?.lockForConfiguration() |
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
class CameraController: NSObject{ | |
var captureSession: AVCaptureSession? | |
var frontCamera: AVCaptureDevice? | |
var frontCameraInput: AVCaptureDeviceInput? | |
var previewLayer: AVCaptureVideoPreviewLayer? | |
enum CameraControllerError: Swift.Error { | |
case captureSessionAlreadyRunning | |
case captureSessionIsMissing | |
case inputsAreInvalid |
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
struct ContentView: View { | |
var body: some View { | |
VStack{ | |
Image("lock") | |
.resizable() | |
.aspectRatio(contentMode: .fill) | |
.frame(width: 200.0, height: 200.0) | |
.cornerRadius(90.0) | |
Text("I am protected by a login page.") | |
} |
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
struct LoginView: View { | |
@State private var username: String = "" | |
@State private var password: String = "" | |
var body: some View { | |
GeometryReader { geometry in | |
VStack{ | |
Image("lock") | |
.resizable() |
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
Text("My text") | |
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading) |
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
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class PlayerMovement : MonoBehaviour { | |
private CharacterController characterController; | |
private Animator animator; | |
private float moveSpeed; | |
private bool hasJumped; |
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
// Future versions of Hyper may add additional config options, | |
// which will not automatically be merged into this file. | |
// See https://hyper.is#cfg for all currently supported options. | |
module.exports = { | |
config: { | |
// choose either `'stable'` for receiving highly polished, | |
// or `'canary'` for less polished but more frequent updates | |
updateChannel: 'stable', |
NewerOlder