no message

This commit is contained in:
Ilya Laktyushin 2018-09-17 22:08:09 +01:00
parent 5e092c8bf5
commit 78dca463ea
3 changed files with 110 additions and 25 deletions

View File

@ -435,28 +435,32 @@ final class SecureIdAuthControllerNode: ViewControllerTracingNode {
switch value.value { switch value.value {
case .passport: case .passport:
hasValueType = .passport hasValueType = .passport
case .internalPassport:
hasValueType = .internalPassport
case .idCard: case .idCard:
hasValueType = .idCard hasValueType = .idCard
case .driversLicense: case .driversLicense:
hasValueType = .driversLicense hasValueType = .driversLicense
case .internalPassport:
hasValueType = .internalPassport
default: default:
break break
} }
} }
case let .oneOf(types): case let .oneOf(types):
for type in types { outer: for type in types {
if let value = findValue(formData.values, key: type.valueKey)?.1 { if let value = findValue(formData.values, key: type.valueKey)?.1 {
switch value.value { switch value.value {
case .passport: case .passport:
hasValueType = .passport hasValueType = .passport
case .internalPassport: break outer
hasValueType = .internalPassport
case .idCard: case .idCard:
hasValueType = .idCard hasValueType = .idCard
break outer
case .driversLicense: case .driversLicense:
hasValueType = .driversLicense hasValueType = .driversLicense
break outer
case .internalPassport:
hasValueType = .internalPassport
break outer
default: default:
break break
} }
@ -487,36 +491,39 @@ final class SecureIdAuthControllerNode: ViewControllerTracingNode {
case let .just(type): case let .just(type):
if let value = findValue(formData.values, key: type.valueKey)?.1 { if let value = findValue(formData.values, key: type.valueKey)?.1 {
switch value.value { switch value.value {
case .rentalAgreement: case .utilityBill:
hasValueType = .rentalAgreement hasValueType = .utilityBill
case .bankStatement: case .bankStatement:
hasValueType = .bankStatement hasValueType = .bankStatement
case .rentalAgreement:
hasValueType = .rentalAgreement
case .passportRegistration: case .passportRegistration:
hasValueType = .passportRegistration hasValueType = .passportRegistration
case .temporaryRegistration: case .temporaryRegistration:
hasValueType = .temporaryRegistration hasValueType = .temporaryRegistration
case .utilityBill:
hasValueType = .utilityBill
default: default:
break break
} }
} }
case let .oneOf(types): case let .oneOf(types):
for type in types { outer: for type in types {
if let value = findValue(formData.values, key: type.valueKey)?.1 { if let value = findValue(formData.values, key: type.valueKey)?.1 {
switch value.value { switch value.value {
case .rentalAgreement:
hasValueType = .rentalAgreement
case .bankStatement:
hasValueType = .bankStatement
case .passportRegistration:
hasValueType = .passportRegistration
case .temporaryRegistration:
hasValueType = .temporaryRegistration
case .utilityBill: case .utilityBill:
hasValueType = .utilityBill hasValueType = .utilityBill
break outer
case .bankStatement:
hasValueType = .bankStatement
break outer
case .rentalAgreement:
hasValueType = .rentalAgreement
break outer
case .passportRegistration:
hasValueType = .passportRegistration
break outer
case .temporaryRegistration:
hasValueType = .temporaryRegistration
break outer
default: default:
break break
} }

View File

@ -503,6 +503,44 @@ private func placeholderForDocumentTypes(_ types: [SecureIdRequestedAddressDocum
return strings.Passport_Address_UploadOneOfScan(string).0 return strings.Passport_Address_UploadOneOfScan(string).0
} }
private func stringForDocumentValue(_ value: SecureIdValue, strings: PresentationStrings) -> String? {
let stringForIdentityDocument: (String, SecureIdDate?) -> String = { identifier, date in
var string = identifier
if let date = date {
string.append(", ")
string.append(stringForDate(timestamp: date.timestamp, strings: strings))
}
return string
}
let stringForAddressDocument: (Int) -> String = { count in
return strings.Passport_Scans(Int32(count))
}
switch value {
case let .passport(value):
return stringForIdentityDocument(value.identifier, value.expiryDate)
case let .internalPassport(value):
return stringForIdentityDocument(value.identifier, value.expiryDate)
case let .idCard(value):
return stringForIdentityDocument(value.identifier, value.expiryDate)
case let .driversLicense(value):
return stringForIdentityDocument(value.identifier, value.expiryDate)
case let .utilityBill(value):
return stringForAddressDocument(value.verificationDocuments.count)
case let .rentalAgreement(value):
return stringForAddressDocument(value.verificationDocuments.count)
case let .bankStatement(value):
return stringForAddressDocument(value.verificationDocuments.count)
case let .temporaryRegistration(value):
return stringForAddressDocument(value.verificationDocuments.count)
case let .passportRegistration(value):
return stringForAddressDocument(value.verificationDocuments.count)
default:
return nil
}
}
private func fieldTitleAndText(field: SecureIdParsedRequestedFormField, strings: PresentationStrings, values: [SecureIdValueWithContext]) -> (String, String) { private func fieldTitleAndText(field: SecureIdParsedRequestedFormField, strings: PresentationStrings, values: [SecureIdValueWithContext]) -> (String, String) {
var title: String var title: String
var placeholder: String var placeholder: String
@ -510,6 +548,9 @@ private func fieldTitleAndText(field: SecureIdParsedRequestedFormField, strings:
switch field { switch field {
case let .identity(personalDetails, document, _, _): case let .identity(personalDetails, document, _, _):
var isOneOf = false
var filledDocument: (SecureIdRequestedIdentityDocument, SecureIdValue)?
if let document = document { if let document = document {
title = strings.Passport_FieldIdentity title = strings.Passport_FieldIdentity
placeholder = strings.Passport_FieldIdentityUploadHelp placeholder = strings.Passport_FieldIdentityUploadHelp
@ -518,20 +559,31 @@ private func fieldTitleAndText(field: SecureIdParsedRequestedFormField, strings:
case let .just(type): case let .just(type):
title = stringForDocumentType(type, strings: strings) title = stringForDocumentType(type, strings: strings)
placeholder = placeholderForDocumentType(type, strings: strings) placeholder = placeholderForDocumentType(type, strings: strings)
break if let value = findValue(values, key: type.valueKey)?.1.value {
filledDocument = (type, value)
}
case let .oneOf(types): case let .oneOf(types):
isOneOf = true
let typesArray = Array(types) let typesArray = Array(types)
if typesArray.count == 2 { if typesArray.count == 2 {
title = strings.Passport_FieldOneOf_Or(stringForDocumentType(typesArray[0], strings: strings), stringForDocumentType(typesArray[1], strings: strings)).0 title = strings.Passport_FieldOneOf_Or(stringForDocumentType(typesArray[0], strings: strings), stringForDocumentType(typesArray[1], strings: strings)).0
} }
placeholder = placeholderForDocumentTypes(typesArray, strings: strings) placeholder = placeholderForDocumentTypes(typesArray, strings: strings)
for type in types {
if let value = findValue(values, key: type.valueKey)?.1.value {
filledDocument = (type, value)
break break
} }
}
}
} else { } else {
title = strings.Passport_Identity_TypePersonalDetails title = strings.Passport_Identity_TypePersonalDetails
placeholder = strings.Passport_FieldIdentityDetailsHelp placeholder = strings.Passport_FieldIdentityDetailsHelp
} }
if let filledDocument = filledDocument, isOneOf {
text = stringForDocumentType(filledDocument.0, strings: strings)
}
if let personalDetails = personalDetails { if let personalDetails = personalDetails {
if let value = findValue(values, key: .personalDetails), case let .personalDetails(personalDetailsValue) = value.1.value { if let value = findValue(values, key: .personalDetails), case let .personalDetails(personalDetailsValue) = value.1.value {
if !text.isEmpty { if !text.isEmpty {
@ -546,7 +598,16 @@ private func fieldTitleAndText(field: SecureIdParsedRequestedFormField, strings:
text.append(fieldsText(fullName, countryName(code: personalDetailsValue.countryCode, strings: strings))) text.append(fieldsText(fullName, countryName(code: personalDetailsValue.countryCode, strings: strings)))
} }
} }
if let filledDocument = filledDocument, let string = stringForDocumentValue(filledDocument.1, strings: strings) {
if !text.isEmpty {
text.append(", ")
}
text.append(string)
}
case let .address(addressDetails, document, _): case let .address(addressDetails, document, _):
var isOneOf = false
var filledDocument: (SecureIdRequestedAddressDocument, SecureIdValue)?
if let document = document { if let document = document {
title = strings.Passport_FieldAddress title = strings.Passport_FieldAddress
placeholder = strings.Passport_FieldAddressUploadHelp placeholder = strings.Passport_FieldAddressUploadHelp
@ -554,20 +615,31 @@ private func fieldTitleAndText(field: SecureIdParsedRequestedFormField, strings:
case let .just(type): case let .just(type):
title = stringForDocumentType(type, strings: strings) title = stringForDocumentType(type, strings: strings)
placeholder = placeholderForDocumentType(type, strings: strings) placeholder = placeholderForDocumentType(type, strings: strings)
break if let value = findValue(values, key: type.valueKey)?.1.value {
filledDocument = (type, value)
}
case let .oneOf(types): case let .oneOf(types):
isOneOf = true
let typesArray = Array(types) let typesArray = Array(types)
if typesArray.count == 2 { if typesArray.count == 2 {
title = strings.Passport_FieldOneOf_Or(stringForDocumentType(typesArray[0], strings: strings), stringForDocumentType(typesArray[1], strings: strings)).0 title = strings.Passport_FieldOneOf_Or(stringForDocumentType(typesArray[0], strings: strings), stringForDocumentType(typesArray[1], strings: strings)).0
} }
placeholder = placeholderForDocumentTypes(typesArray, strings: strings) placeholder = placeholderForDocumentTypes(typesArray, strings: strings)
for type in types {
if let value = findValue(values, key: type.valueKey)?.1.value {
filledDocument = (type, value)
break break
} }
}
}
} else { } else {
title = strings.Passport_FieldAddress title = strings.Passport_FieldAddress
placeholder = strings.Passport_FieldAddressHelp placeholder = strings.Passport_FieldAddressHelp
} }
if let filledDocument = filledDocument, isOneOf {
text = stringForDocumentType(filledDocument.0, strings: strings)
}
if addressDetails { if addressDetails {
if let value = findValue(values, key: .address), case let .address(addressValue) = value.1.value { if let value = findValue(values, key: .address), case let .address(addressValue) = value.1.value {
if !text.isEmpty { if !text.isEmpty {
@ -576,6 +648,12 @@ private func fieldTitleAndText(field: SecureIdParsedRequestedFormField, strings:
text.append(fieldsText(addressValue.street1, addressValue.street2, addressValue.city, addressValue.state, addressValue.postcode, countryName(code: addressValue.countryCode, strings: strings))) text.append(fieldsText(addressValue.street1, addressValue.street2, addressValue.city, addressValue.state, addressValue.postcode, countryName(code: addressValue.countryCode, strings: strings)))
} }
} }
if let filledDocument = filledDocument, let string = stringForDocumentValue(filledDocument.1, strings: strings) {
if !text.isEmpty {
text.append(", ")
}
text.append(string)
}
case .phone: case .phone:
title = strings.Passport_FieldPhone title = strings.Passport_FieldPhone
placeholder = strings.Passport_FieldPhoneHelp placeholder = strings.Passport_FieldPhoneHelp