diff --git a/AttestationCovid/Certificate/CertificateDocumentBuilder.swift b/AttestationCovid/Certificate/CertificateDocumentBuilder.swift index 7d8197b..0a39873 100644 --- a/AttestationCovid/Certificate/CertificateDocumentBuilder.swift +++ b/AttestationCovid/Certificate/CertificateDocumentBuilder.swift @@ -28,43 +28,45 @@ struct CertificateDocumentBuilder { let mainPage = document.page(at: 0) let pageWidth = mainPage?.bounds(for: .mediaBox).width ?? 600 - mainPage?.addAnnotation(makeTextAnnotation(text: attestation.displayName, x: 123, y: 686, width: .fittingPage(pageWidth))) - mainPage?.addAnnotation(makeTextAnnotation(text: attestation.birthdate, x: 123, y: 661, width: .fittingPage(pageWidth))) - mainPage?.addAnnotation(makeTextAnnotation(text: attestation.birthplace, x: 92, y: 638, width: .fittingPage(pageWidth))) - mainPage?.addAnnotation(makeTextAnnotation(text: attestation.fullAddress, x: 134, y: 613, width: .fittingPage(pageWidth))) + mainPage?.addAnnotation(makeTextAnnotation(text: attestation.displayName, x: 115, y: 698, width: .fittingPage(pageWidth))) + mainPage?.addAnnotation(makeTextAnnotation(text: attestation.birthdate, x: 115, y: 675, width: .fittingPage(pageWidth))) + mainPage?.addAnnotation(makeTextAnnotation(text: attestation.birthplace, x: 295, y: 675, width: .fittingPage(pageWidth))) + mainPage?.addAnnotation(makeTextAnnotation(text: attestation.fullAddress, x: 130, y: 653, width: .fittingPage(pageWidth))) if attestation.motives.contains(.pro) { - mainPage?.addAnnotation(makeCheckmarkAnnotation(x: 74, y: 527)) + mainPage?.addAnnotation(makeCheckmarkAnnotation(x: 80, y: 577)) } if attestation.motives.contains(.shop) { - mainPage?.addAnnotation(makeCheckmarkAnnotation(x: 74, y: 478)) + mainPage?.addAnnotation(makeCheckmarkAnnotation(x: 80, y: 532)) } if attestation.motives.contains(.health) { - mainPage?.addAnnotation(makeCheckmarkAnnotation(x: 74, y: 436)) + mainPage?.addAnnotation(makeCheckmarkAnnotation(x: 80, y: 477)) } if attestation.motives.contains(.family) { - mainPage?.addAnnotation(makeCheckmarkAnnotation(x: 74, y: 400)) + mainPage?.addAnnotation(makeCheckmarkAnnotation(x: 80, y: 435)) + } + if attestation.motives.contains(.disabledPeopleTransport) { + mainPage?.addAnnotation(makeCheckmarkAnnotation(x: 80, y: 395)) } if attestation.motives.contains(.brief) { - mainPage?.addAnnotation(makeCheckmarkAnnotation(x: 74, y: 345)) + mainPage?.addAnnotation(makeCheckmarkAnnotation(x: 80, y: 355)) } if attestation.motives.contains(.administrative) { - mainPage?.addAnnotation(makeCheckmarkAnnotation(x: 74, y: 298)) + mainPage?.addAnnotation(makeCheckmarkAnnotation(x: 80, y: 295)) } if attestation.motives.contains(.tig) { - mainPage?.addAnnotation(makeCheckmarkAnnotation(x: 74, y: 260)) + mainPage?.addAnnotation(makeCheckmarkAnnotation(x: 80, y: 254)) + } + if attestation.motives.contains(.school) { + mainPage?.addAnnotation(makeCheckmarkAnnotation(x: 80, y: 210)) } - mainPage?.addAnnotation(makeTextAnnotation(text: attestation.city, x: 111, y: 226, width: .fittingPage(pageWidth))) - mainPage?.addAnnotation(makeTextAnnotation(text: attestation.formattedDate, x: 92, y: 200, width: .width(80))) - mainPage?.addAnnotation(makeTextAnnotation(text: attestation.formattedHour, x: 198, y: 201, width: .width(20))) - mainPage?.addAnnotation(makeTextAnnotation(text: attestation.formattedMinute, x: 218, y: 201, width: .width(20))) - - let qrImage = try CertificateQRCodeBuilder.build(from: attestation, creationDate: creationDate) - mainPage?.addAnnotation(makeImageAnnotation(image: qrImage, x: pageWidth - 170, y: 157, width: 100, height: 100)) - makeCreationDateAnnotations(creationDate: creationDate).forEach { mainPage?.addAnnotation($0) } + mainPage?.addAnnotation(makeTextAnnotation(text: attestation.city, x: 106, y: 175, width: .fittingPage(pageWidth))) + mainPage?.addAnnotation(makeTextAnnotation(text: attestation.formattedDate, x: 92, y: 153, width: .width(80))) + mainPage?.addAnnotation(makeTextAnnotation(text: attestation.formattedTime, x: 255, y: 153, width: .width(80))) let qrPage = PDFPage() + let qrImage = try CertificateQRCodeBuilder.build(from: attestation, creationDate: creationDate) let qrPageHeight = qrPage.bounds(for: .mediaBox).height qrPage.addAnnotation(makeImageAnnotation(image: qrImage, x: 50, y: qrPageHeight - 350, width: 300, height: 300)) document.insert(qrPage, at: 1) diff --git a/AttestationCovid/Form/FormViewController.swift b/AttestationCovid/Form/FormViewController.swift index edcd117..bdf1072 100644 --- a/AttestationCovid/Form/FormViewController.swift +++ b/AttestationCovid/Form/FormViewController.swift @@ -150,6 +150,16 @@ final class FormViewController: UITableViewController { } } return cell + case (.motives, FormSection.MotivesContent.disabledPeopleTransport.rawValue): + let cell = self.checkCell(tableView, indexPath: indexPath) + cell.configure(content: NSLocalizedString("motive.disabledPeopleTransport", comment: ""), selected: attestation.motives.contains(.disabledPeopleTransport)) { [weak self] value in + if value { + self?.attestation.motives.insert(.disabledPeopleTransport) + } else { + self?.attestation.motives.remove(.disabledPeopleTransport) + } + } + return cell case (.motives, FormSection.MotivesContent.brief.rawValue): let cell = self.checkCell(tableView, indexPath: indexPath) cell.configure(content: NSLocalizedString("motive.brief", comment: ""), selected: attestation.motives.contains(.brief)) { [weak self] value in @@ -180,6 +190,16 @@ final class FormViewController: UITableViewController { } } return cell + case (.motives, FormSection.MotivesContent.school.rawValue): + let cell = self.checkCell(tableView, indexPath: indexPath) + cell.configure(content: NSLocalizedString("motive.school", comment: ""), selected: attestation.motives.contains(.school)) { [weak self] value in + if value { + self?.attestation.motives.insert(.school) + } else { + self?.attestation.motives.remove(.school) + } + } + return cell // DATE section case (.date, FormSection.DateContent.date.rawValue): diff --git a/AttestationCovid/Form/FormViewModels.swift b/AttestationCovid/Form/FormViewModels.swift index b831da7..45f2484 100644 --- a/AttestationCovid/Form/FormViewModels.swift +++ b/AttestationCovid/Form/FormViewModels.swift @@ -24,9 +24,11 @@ enum FormSection: Int, CaseIterable { case shop case health case family + case disabledPeopleTransport case brief case administrative case tig + case school } enum DateContent: Int, CaseIterable { diff --git a/AttestationCovid/Models/Certificate.swift b/AttestationCovid/Models/Certificate.swift index 0918874..200b512 100644 --- a/AttestationCovid/Models/Certificate.swift +++ b/AttestationCovid/Models/Certificate.swift @@ -29,9 +29,11 @@ struct Certificate: Codable { static let shop = Motive(rawValue: 1 << 1) static let health = Motive(rawValue: 1 << 2) static let family = Motive(rawValue: 1 << 3) - static let brief = Motive(rawValue: 1 << 4) - static let administrative = Motive(rawValue: 1 << 5) - static let tig = Motive(rawValue: 1 << 6) + static let disabledPeopleTransport = Motive(rawValue: 1 << 4) + static let brief = Motive(rawValue: 1 << 5) + static let administrative = Motive(rawValue: 1 << 6) + static let tig = Motive(rawValue: 1 << 7) + static let school = Motive(rawValue: 1 << 8) var displayableValue: String { var values: [String] = [] @@ -39,9 +41,11 @@ struct Certificate: Codable { if contains(.shop) { values.append("courses") } if contains(.health) { values.append("sante") } if contains(.family) { values.append("famille") } + if contains(.disabledPeopleTransport) { values.append("déplacement des personnes en situtation de handicap") } if contains(.brief) { values.append("sport") } if contains(.administrative) { values.append("judiciaire") } if contains(.tig) { values.append("missions") } + if contains(.school) { values.append("école") } return values.joined(separator: "-") } @@ -68,6 +72,10 @@ struct Certificate: Codable { var formattedDate: String { return DateFormatter.date.string(from: date) } + + var formattedTime: String { + return DateFormatter.time.string(from: date) + } var formattedHour: String { return DateFormatter.hour.string(from: date) diff --git a/AttestationCovid/certificate.pdf b/AttestationCovid/certificate.pdf index 3ebb195..1d47c84 100644 Binary files a/AttestationCovid/certificate.pdf and b/AttestationCovid/certificate.pdf differ diff --git a/AttestationCovid/fr.lproj/Localizable.strings b/AttestationCovid/fr.lproj/Localizable.strings index 8d09d0c..155fe30 100644 --- a/AttestationCovid/fr.lproj/Localizable.strings +++ b/AttestationCovid/fr.lproj/Localizable.strings @@ -10,9 +10,11 @@ "motive.shop" = "Déplacements pour effectuer des achats de fournitures nécessaires à l’activité professionnelle et des achats de première nécessité dans des établissements dont les activités demeurent autorisées (liste sur gouvernement.fr)."; "motive.health" = "Consultations et soins ne pouvant être assurés à distance et ne pouvant être différés ; consultations et soins des patients atteints d'une affection de longue durée."; "motive.family" = "Déplacements pour motif familial impérieux, pour l’assistance aux personnes vulnérables ou la garde d’enfants."; +"motive.disabledPeopleTransport" = "Déplacement des personnes en situation de handicap et leur accompagnant."; "motive.brief" = "Déplacements brefs, dans la limite d'une heure quotidienne et dans un rayon maximal d'un kilomètre autour du domicile, liés soit à l'activité physique individuelle des personnes, à l'exclusion de toute pratique sportive collective et de toute proximité avec d'autres personnes, soit à la promenade avec les seules personnes regroupées dans un même domicile, soit aux besoins des animaux de compagnie."; "motive.administrative" = "Convocation judiciaire ou administrative."; "motive.tig" = "Participation à des missions d’intérêt général sur demande de l’autorité administrative."; +"motive.school" = "Déplacement pour chercher les enfants à l’école et à l’occasion de leurs activités périscolaire."; "date" = "Date de sortie"; "time" = "Heure de sortie";