Skip to content

Commit

Permalink
chore: update missing localization strings for face not prepared reas…
Browse files Browse the repository at this point in the history
…ons (#79)

* add preview/hair check screen

* chore(ux): add error log message

* chore(ux): update handling of camera permissions

* chore: reset integration test

* fix build error

* fix build error

* chore: update missing localization strings for face not prepared reasons

* resolve duplicate code from merge error
  • Loading branch information
phantumcode authored Nov 29, 2023
1 parent ba5e1ae commit 15de0d1
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 13 deletions.
11 changes: 11 additions & 0 deletions Sources/FaceLiveness/Resources/Base.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,14 @@
"amplify_ui_liveness_camera_permission_button_title" = "Change Camera Setting";
"amplify_ui_liveness_camera_permission_button_header" = "Camera is not accessible";
"amplify_ui_liveness_camera_permission_button_description" = "You may have to go into settings to grant camera permissions and close the app and retry.";

"amplify_ui_liveness_face_not_prepared_reason_pendingCheck" = "";
"amplify_ui_liveness_face_not_prepared_reason_not_in_oval" = "Move face to fit in oval";
"amplify_ui_liveness_face_not_prepared_reason_move_face_closer" = "Move closer";
"amplify_ui_liveness_face_not_prepared_reason_move_face_right" = "Move face right";
"amplify_ui_liveness_face_not_prepared_reason_move_face_left" = "Move face left";
"amplify_ui_liveness_face_not_prepared_reason_move_to_dimmer_area" = "Move to dimmer area";
"amplify_ui_liveness_face_not_prepared_reason_move_to_brighter_area" = "Move to brighter area";
"amplify_ui_liveness_face_not_prepared_reason_no_face" = "Move face in front of camera";
"amplify_ui_liveness_face_not_prepared_reason_multiple_faces" = "Only one face per check";
"amplify_ui_liveness_face_not_prepared_reason_face_too_close" = "Move face farther away";
30 changes: 30 additions & 0 deletions Sources/FaceLiveness/Utilities/LivenessLocalizedStrings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,34 @@ enum LocalizedStrings {

/// en = "You may have to go into settings to grant camera permissions and close the app and retry"
static let camera_permission_change_setting_description = "amplify_ui_liveness_camera_permission_button_description".localized()

/// en = ""
static let amplify_ui_liveness_face_not_prepared_reason_pendingCheck = "amplify_ui_liveness_face_not_prepared_reason_pendingCheck".localized()

/// en = "Move face to fit in oval"
static let amplify_ui_liveness_face_not_prepared_reason_not_in_oval = "amplify_ui_liveness_face_not_prepared_reason_not_in_oval".localized()

/// en = "Move closer"
static let amplify_ui_liveness_face_not_prepared_reason_move_face_closer = "amplify_ui_liveness_face_not_prepared_reason_move_face_closer".localized()

/// en = "Move face right"
static let amplify_ui_liveness_face_not_prepared_reason_move_face_right = "amplify_ui_liveness_face_not_prepared_reason_move_face_right".localized()

/// en = "Move face left"
static let amplify_ui_liveness_face_not_prepared_reason_move_face_left = "amplify_ui_liveness_face_not_prepared_reason_move_face_left".localized()

/// en = "Move to dimmer area"
static let amplify_ui_liveness_face_not_prepared_reason_move_to_dimmer_area = "amplify_ui_liveness_face_not_prepared_reason_move_to_dimmer_area".localized()

/// en = "Move to brighter area"
static let amplify_ui_liveness_face_not_prepared_reason_move_to_brighter_area = "amplify_ui_liveness_face_not_prepared_reason_move_to_brighter_area".localized()

/// en = "Move face in front of camera"
static let amplify_ui_liveness_face_not_prepared_reason_no_face = "amplify_ui_liveness_face_not_prepared_reason_no_face".localized()

/// en = "Ensure only one face is in front of camera"
static let amplify_ui_liveness_face_not_prepared_reason_multiple_faces = "amplify_ui_liveness_face_not_prepared_reason_multiple_faces".localized()

/// en = "Move face farther away"
static let amplify_ui_liveness_face_not_prepared_reason_face_too_close = "amplify_ui_liveness_face_not_prepared_reason_face_too_close".localized()
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct InstructionContainerView: View {

case .awaitingFaceInOvalMatch(let reason, let percentage):
InstructionView(
text: .init(reason.rawValue),
text: .init(reason.localizedValue),
backgroundColor: .livenessPrimaryBackground,
textColor: .livenessPrimaryLabel,
font: .title
Expand Down Expand Up @@ -81,7 +81,7 @@ struct InstructionContainerView: View {
.frame(width: 200, height: 30)
case .pendingFacePreparedConfirmation(let reason):
InstructionView(
text: .init(reason.rawValue),
text: .init(reason.localizedValue),
backgroundColor: .livenessPrimaryBackground,
textColor: .livenessPrimaryLabel,
font: .title
Expand Down
47 changes: 36 additions & 11 deletions Sources/FaceLiveness/Views/Liveness/LivenessStateMachine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,42 @@ struct LivenessStateMachine {
case waitForRecording
}

enum FaceNotPreparedReason: String, Equatable {
case pendingCheck = ""
case notInOval = "Move face to fit in oval"
case moveFaceCloser = "Move closer"
case moveFaceRight = "Move face right"
case moveFaceLeft = "Move face left"
case moveToDimmerArea = "Move to dimmer area"
case moveToBrighterArea = "Move to brighter area"
case noFace = "Move face in front of camera"
case multipleFaces = "Ensure only one face is in front of camera"
case faceTooClose = "Move face farther away"
enum FaceNotPreparedReason {
case pendingCheck
case notInOval
case moveFaceCloser
case moveFaceRight
case moveFaceLeft
case moveToDimmerArea
case moveToBrighterArea
case noFace
case multipleFaces
case faceTooClose

var localizedValue: String {
switch self {
case .pendingCheck:
return LocalizedStrings.amplify_ui_liveness_face_not_prepared_reason_pendingCheck
case .notInOval:
return LocalizedStrings.amplify_ui_liveness_face_not_prepared_reason_not_in_oval
case .moveFaceCloser:
return LocalizedStrings.amplify_ui_liveness_face_not_prepared_reason_move_face_closer
case .moveFaceRight:
return LocalizedStrings.amplify_ui_liveness_face_not_prepared_reason_move_face_right
case .moveFaceLeft:
return LocalizedStrings.amplify_ui_liveness_face_not_prepared_reason_move_face_left
case .moveToDimmerArea:
return LocalizedStrings.amplify_ui_liveness_face_not_prepared_reason_move_to_dimmer_area
case .moveToBrighterArea:
return LocalizedStrings.amplify_ui_liveness_face_not_prepared_reason_move_to_brighter_area
case .noFace:
return LocalizedStrings.amplify_ui_liveness_face_not_prepared_reason_no_face
case .multipleFaces:
return LocalizedStrings.challenge_instruction_multiple_faces_detected
case .faceTooClose:
return LocalizedStrings.amplify_ui_liveness_face_not_prepared_reason_face_too_close
}
}
}

struct LivenessError: Error, Equatable {
Expand Down

0 comments on commit 15de0d1

Please sign in to comment.