From e9276fb78fb994cbd165c75288f4d72a08edb29b Mon Sep 17 00:00:00 2001 From: Tuan Pham Date: Wed, 29 Nov 2023 10:17:43 -0600 Subject: [PATCH] chore: update per review feedback --- .../Utilities/CGImage+Convert.swift | 24 ++++++++++--------- .../GetReadyPage/CameraPreviewView.swift | 2 +- .../GetReadyPage/CameraPreviewViewModel.swift | 4 ++-- .../Views/GetReadyPage/ImageFrameView.swift | 21 ++++++++-------- 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/Sources/FaceLiveness/Utilities/CGImage+Convert.swift b/Sources/FaceLiveness/Utilities/CGImage+Convert.swift index 885ecf0f..7304392a 100644 --- a/Sources/FaceLiveness/Utilities/CGImage+Convert.swift +++ b/Sources/FaceLiveness/Utilities/CGImage+Convert.swift @@ -9,16 +9,18 @@ import CoreGraphics import VideoToolbox extension CGImage { - static func convert(from cvPixelBuffer: CVPixelBuffer?) -> CGImage? { - guard let pixelBuffer = cvPixelBuffer else { - return nil - } + static func convert(from cvPixelBuffer: CVPixelBuffer?) -> CGImage? { + guard let pixelBuffer = cvPixelBuffer else { + return nil + } - var image: CGImage? - VTCreateCGImageFromCVPixelBuffer( - pixelBuffer, - options: nil, - imageOut: &image) - return image - } + var image: CGImage? + VTCreateCGImageFromCVPixelBuffer( + pixelBuffer, + options: nil, + imageOut: &image + ) + + return image + } } diff --git a/Sources/FaceLiveness/Views/GetReadyPage/CameraPreviewView.swift b/Sources/FaceLiveness/Views/GetReadyPage/CameraPreviewView.swift index b815b723..f78e8df0 100644 --- a/Sources/FaceLiveness/Views/GetReadyPage/CameraPreviewView.swift +++ b/Sources/FaceLiveness/Views/GetReadyPage/CameraPreviewView.swift @@ -15,7 +15,7 @@ struct CameraPreviewView: View { @StateObject var model: CameraPreviewViewModel - public init(model: CameraPreviewViewModel = CameraPreviewViewModel()) { + init(model: CameraPreviewViewModel = CameraPreviewViewModel()) { self._model = StateObject(wrappedValue: model) } diff --git a/Sources/FaceLiveness/Views/GetReadyPage/CameraPreviewViewModel.swift b/Sources/FaceLiveness/Views/GetReadyPage/CameraPreviewViewModel.swift index 61f8e8ec..eb661451 100644 --- a/Sources/FaceLiveness/Views/GetReadyPage/CameraPreviewViewModel.swift +++ b/Sources/FaceLiveness/Views/GetReadyPage/CameraPreviewViewModel.swift @@ -21,14 +21,14 @@ class CameraPreviewViewModel: NSObject, ObservableObject { super.init() setupSubscriptions() - let avCpatureDevice = AVCaptureDevice.DiscoverySession( + let avCaptureDevice = AVCaptureDevice.DiscoverySession( deviceTypes: [.builtInWideAngleCamera], mediaType: .video, position: .front ).devices.first self.previewCaptureSession = LivenessCaptureSession( - captureDevice: .init(avCaptureDevice: avCpatureDevice), + captureDevice: .init(avCaptureDevice: avCaptureDevice), outputDelegate: self ) diff --git a/Sources/FaceLiveness/Views/GetReadyPage/ImageFrameView.swift b/Sources/FaceLiveness/Views/GetReadyPage/ImageFrameView.swift index e2aedbed..63052904 100644 --- a/Sources/FaceLiveness/Views/GetReadyPage/ImageFrameView.swift +++ b/Sources/FaceLiveness/Views/GetReadyPage/ImageFrameView.swift @@ -12,20 +12,19 @@ struct ImageFrameView: View { var body: some View { if let image = image { - GeometryReader { geometry in - Image(decorative: image, scale: 1.0, orientation: .upMirrored) - .resizable() - .scaledToFill() - .frame( - width: geometry.size.width, - height: geometry.size.height, - alignment: .center) - .clipped() - } + GeometryReader { geometry in + Image(decorative: image, scale: 1.0, orientation: .upMirrored) + .resizable() + .scaledToFill() + .frame( + width: geometry.size.width, + height: geometry.size.height, + alignment: .center) + .clipped() + } } else { Color.black } - } }