Skip to content

Commit 15de0d1

Browse files
authored
chore: update missing localization strings for face not prepared reasons (#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
1 parent ba5e1ae commit 15de0d1

File tree

4 files changed

+79
-13
lines changed

4 files changed

+79
-13
lines changed

Sources/FaceLiveness/Resources/Base.lproj/Localizable.strings

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,14 @@
3838
"amplify_ui_liveness_camera_permission_button_title" = "Change Camera Setting";
3939
"amplify_ui_liveness_camera_permission_button_header" = "Camera is not accessible";
4040
"amplify_ui_liveness_camera_permission_button_description" = "You may have to go into settings to grant camera permissions and close the app and retry.";
41+
42+
"amplify_ui_liveness_face_not_prepared_reason_pendingCheck" = "";
43+
"amplify_ui_liveness_face_not_prepared_reason_not_in_oval" = "Move face to fit in oval";
44+
"amplify_ui_liveness_face_not_prepared_reason_move_face_closer" = "Move closer";
45+
"amplify_ui_liveness_face_not_prepared_reason_move_face_right" = "Move face right";
46+
"amplify_ui_liveness_face_not_prepared_reason_move_face_left" = "Move face left";
47+
"amplify_ui_liveness_face_not_prepared_reason_move_to_dimmer_area" = "Move to dimmer area";
48+
"amplify_ui_liveness_face_not_prepared_reason_move_to_brighter_area" = "Move to brighter area";
49+
"amplify_ui_liveness_face_not_prepared_reason_no_face" = "Move face in front of camera";
50+
"amplify_ui_liveness_face_not_prepared_reason_multiple_faces" = "Only one face per check";
51+
"amplify_ui_liveness_face_not_prepared_reason_face_too_close" = "Move face farther away";

Sources/FaceLiveness/Utilities/LivenessLocalizedStrings.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,34 @@ enum LocalizedStrings {
8888

8989
/// en = "You may have to go into settings to grant camera permissions and close the app and retry"
9090
static let camera_permission_change_setting_description = "amplify_ui_liveness_camera_permission_button_description".localized()
91+
92+
/// en = ""
93+
static let amplify_ui_liveness_face_not_prepared_reason_pendingCheck = "amplify_ui_liveness_face_not_prepared_reason_pendingCheck".localized()
94+
95+
/// en = "Move face to fit in oval"
96+
static let amplify_ui_liveness_face_not_prepared_reason_not_in_oval = "amplify_ui_liveness_face_not_prepared_reason_not_in_oval".localized()
97+
98+
/// en = "Move closer"
99+
static let amplify_ui_liveness_face_not_prepared_reason_move_face_closer = "amplify_ui_liveness_face_not_prepared_reason_move_face_closer".localized()
100+
101+
/// en = "Move face right"
102+
static let amplify_ui_liveness_face_not_prepared_reason_move_face_right = "amplify_ui_liveness_face_not_prepared_reason_move_face_right".localized()
103+
104+
/// en = "Move face left"
105+
static let amplify_ui_liveness_face_not_prepared_reason_move_face_left = "amplify_ui_liveness_face_not_prepared_reason_move_face_left".localized()
106+
107+
/// en = "Move to dimmer area"
108+
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()
109+
110+
/// en = "Move to brighter area"
111+
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()
112+
113+
/// en = "Move face in front of camera"
114+
static let amplify_ui_liveness_face_not_prepared_reason_no_face = "amplify_ui_liveness_face_not_prepared_reason_no_face".localized()
115+
116+
/// en = "Ensure only one face is in front of camera"
117+
static let amplify_ui_liveness_face_not_prepared_reason_multiple_faces = "amplify_ui_liveness_face_not_prepared_reason_multiple_faces".localized()
118+
119+
/// en = "Move face farther away"
120+
static let amplify_ui_liveness_face_not_prepared_reason_face_too_close = "amplify_ui_liveness_face_not_prepared_reason_face_too_close".localized()
91121
}

Sources/FaceLiveness/Views/Instruction/InstructionContainerView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct InstructionContainerView: View {
4343

4444
case .awaitingFaceInOvalMatch(let reason, let percentage):
4545
InstructionView(
46-
text: .init(reason.rawValue),
46+
text: .init(reason.localizedValue),
4747
backgroundColor: .livenessPrimaryBackground,
4848
textColor: .livenessPrimaryLabel,
4949
font: .title
@@ -81,7 +81,7 @@ struct InstructionContainerView: View {
8181
.frame(width: 200, height: 30)
8282
case .pendingFacePreparedConfirmation(let reason):
8383
InstructionView(
84-
text: .init(reason.rawValue),
84+
text: .init(reason.localizedValue),
8585
backgroundColor: .livenessPrimaryBackground,
8686
textColor: .livenessPrimaryLabel,
8787
font: .title

Sources/FaceLiveness/Views/Liveness/LivenessStateMachine.swift

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,42 @@ struct LivenessStateMachine {
109109
case waitForRecording
110110
}
111111

112-
enum FaceNotPreparedReason: String, Equatable {
113-
case pendingCheck = ""
114-
case notInOval = "Move face to fit in oval"
115-
case moveFaceCloser = "Move closer"
116-
case moveFaceRight = "Move face right"
117-
case moveFaceLeft = "Move face left"
118-
case moveToDimmerArea = "Move to dimmer area"
119-
case moveToBrighterArea = "Move to brighter area"
120-
case noFace = "Move face in front of camera"
121-
case multipleFaces = "Ensure only one face is in front of camera"
122-
case faceTooClose = "Move face farther away"
112+
enum FaceNotPreparedReason {
113+
case pendingCheck
114+
case notInOval
115+
case moveFaceCloser
116+
case moveFaceRight
117+
case moveFaceLeft
118+
case moveToDimmerArea
119+
case moveToBrighterArea
120+
case noFace
121+
case multipleFaces
122+
case faceTooClose
123+
124+
var localizedValue: String {
125+
switch self {
126+
case .pendingCheck:
127+
return LocalizedStrings.amplify_ui_liveness_face_not_prepared_reason_pendingCheck
128+
case .notInOval:
129+
return LocalizedStrings.amplify_ui_liveness_face_not_prepared_reason_not_in_oval
130+
case .moveFaceCloser:
131+
return LocalizedStrings.amplify_ui_liveness_face_not_prepared_reason_move_face_closer
132+
case .moveFaceRight:
133+
return LocalizedStrings.amplify_ui_liveness_face_not_prepared_reason_move_face_right
134+
case .moveFaceLeft:
135+
return LocalizedStrings.amplify_ui_liveness_face_not_prepared_reason_move_face_left
136+
case .moveToDimmerArea:
137+
return LocalizedStrings.amplify_ui_liveness_face_not_prepared_reason_move_to_dimmer_area
138+
case .moveToBrighterArea:
139+
return LocalizedStrings.amplify_ui_liveness_face_not_prepared_reason_move_to_brighter_area
140+
case .noFace:
141+
return LocalizedStrings.amplify_ui_liveness_face_not_prepared_reason_no_face
142+
case .multipleFaces:
143+
return LocalizedStrings.challenge_instruction_multiple_faces_detected
144+
case .faceTooClose:
145+
return LocalizedStrings.amplify_ui_liveness_face_not_prepared_reason_face_too_close
146+
}
147+
}
123148
}
124149

125150
struct LivenessError: Error, Equatable {

0 commit comments

Comments
 (0)