Skip to content

Commit

Permalink
chore: update UX
Browse files Browse the repository at this point in the history
  • Loading branch information
phantumcode committed Nov 28, 2023
1 parent 3de4915 commit ea75f06
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
13 changes: 3 additions & 10 deletions Sources/FaceLiveness/Views/GetReadyPage/CameraPreviewView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import SwiftUI

struct CameraPreviewView: View {
private static let previewWidthRatio = 0.6
private static let previewHeightRatio = 0.75
private static let previewWidthRatio = 0.65
private static let previewHeightRatio = 0.6
private static let previewXPositionRatio = 0.5
private static let previewYPositionRatio = 0.55
private static let previewYPositionRatio = 0.5

@StateObject var model: CameraPreviewViewModel

Expand Down Expand Up @@ -39,13 +39,6 @@ struct CameraPreviewView: View {
.position(x: geometry.size.width*Self.previewXPositionRatio,
y: geometry.size.height*Self.previewYPositionRatio)
}
VStack {
Text(LocalizedStrings.preview_center_your_face_text)
.font(.largeTitle)
.multilineTextAlignment(.center)
.padding()
Spacer()
}
}
}
}
Expand Down
31 changes: 19 additions & 12 deletions Sources/FaceLiveness/Views/GetReadyPage/GetReadyPageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,43 @@ import SwiftUI
struct GetReadyPageView: View {
let beginCheckButtonDisabled: Bool
let onBegin: () -> Void
let onCancel: () -> Void

init(
onBegin: @escaping () -> Void,
onCancel: @escaping () -> Void,
beginCheckButtonDisabled: Bool = false
) {
self.onBegin = onBegin
self.onCancel = onCancel
self.beginCheckButtonDisabled = beginCheckButtonDisabled
}

var body: some View {
VStack {
VStack(alignment: .leading) {
Text(LocalizedStrings.get_ready_page_title)
.font(.system(size: 34, weight: .semibold))
.accessibilityAddTraits(.isHeader)
.padding(.bottom, 8)
ZStack {
CameraPreviewView()
VStack {
HStack(alignment: .top) {
Spacer()

CloseButton(
action: onCancel
)
}
Text(LocalizedStrings.preview_center_your_face_text)
.font(.title)
.multilineTextAlignment(.center)

Spacer()
WarningBox(
titleText: LocalizedStrings.get_ready_photosensitivity_title,
bodyText: LocalizedStrings.get_ready_photosensitivity_description,
popoverContent: { photosensitivityWarningPopoverContent }
)
.accessibilityElement(children: .combine)
.padding(.bottom, 8)

CameraPreviewView()
.border(Color.livenessPreviewBorder)
}
.padding()

}
beginCheckButton
}
}
Expand Down Expand Up @@ -76,6 +83,6 @@ struct GetReadyPageView: View {

struct GetReadyPageView_Previews: PreviewProvider {
static var previews: some View {
GetReadyPageView(onBegin: {})
GetReadyPageView(onBegin: {}, onCancel: {})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public struct FaceLivenessDetectorView: View {
guard displayState != .displayingLiveness else { return }
displayState = .displayingLiveness
},
onCancel: { onCompletion(.failure(.userCancelled)) },
beginCheckButtonDisabled: false
)
.onAppear {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class FaceLivenessDetectionViewModel: ObservableObject {
}

@objc func willResignActive(_ notification: Notification) {
guard self.livenessState.state != .initial else { return }
DispatchQueue.main.async {
self.stopRecording()
self.livenessState.unrecoverableStateEncountered(.viewResignation)
Expand Down

0 comments on commit ea75f06

Please sign in to comment.