Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
Merge pull request #4921 from corona-warn-app/task/14280-Add-entry-to…
Browse files Browse the repository at this point in the history
…-contact-journal

Task/14280 add entry to contact journal
  • Loading branch information
30mar authored Dec 7, 2022
2 parents 4203819 + 29ba1fb commit 239576d
Show file tree
Hide file tree
Showing 26 changed files with 502 additions and 58 deletions.
20 changes: 20 additions & 0 deletions src/xcode/ENA/ENA.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,9 @@
8F3D71AA25A86AD300D52CCD /* HomeExposureLoggingCellModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F3D71A925A86AD300D52CCD /* HomeExposureLoggingCellModelTests.swift */; };
8F43A3CB25D55A3E008FD630 /* ppa_data.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F43A3C925D55A3D008FD630 /* ppa_data.pb.swift */; };
8F43A3CC25D55A3E008FD630 /* ppa_data_request_ios.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F43A3CA25D55A3E008FD630 /* ppa_data_request_ios.pb.swift */; };
8F47CB67293E35C5008D91E5 /* ContactDiaryStoreSchemaV6.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F47CB66293E35C5008D91E5 /* ContactDiaryStoreSchemaV6.swift */; };
8F47CB69293E376A008D91E5 /* ContactDiaryMigration5To6.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F47CB68293E376A008D91E5 /* ContactDiaryMigration5To6.swift */; };
8F47CB6B293E4170008D91E5 /* DiaryDaySubmission.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F47CB6A293E4170008D91E5 /* DiaryDaySubmission.swift */; };
8F48192527C68DD1003C06EC /* CCLScenariosHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F48192427C68DD1003C06EC /* CCLScenariosHelper.swift */; };
8F499B03267CDE420047C1A6 /* ManageStatisticsCardView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8F499B02267CDE420047C1A6 /* ManageStatisticsCardView.xib */; };
8F499B05267CDE530047C1A6 /* ManageStatisticsCardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F499B04267CDE530047C1A6 /* ManageStatisticsCardView.swift */; };
Expand Down Expand Up @@ -2892,6 +2895,9 @@
8F3D71A925A86AD300D52CCD /* HomeExposureLoggingCellModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeExposureLoggingCellModelTests.swift; sourceTree = "<group>"; };
8F43A3C925D55A3D008FD630 /* ppa_data.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ppa_data.pb.swift; sourceTree = "<group>"; };
8F43A3CA25D55A3E008FD630 /* ppa_data_request_ios.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ppa_data_request_ios.pb.swift; sourceTree = "<group>"; };
8F47CB66293E35C5008D91E5 /* ContactDiaryStoreSchemaV6.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactDiaryStoreSchemaV6.swift; sourceTree = "<group>"; };
8F47CB68293E376A008D91E5 /* ContactDiaryMigration5To6.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactDiaryMigration5To6.swift; sourceTree = "<group>"; };
8F47CB6A293E4170008D91E5 /* DiaryDaySubmission.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiaryDaySubmission.swift; sourceTree = "<group>"; };
8F48192427C68DD1003C06EC /* CCLScenariosHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CCLScenariosHelper.swift; sourceTree = "<group>"; };
8F499B02267CDE420047C1A6 /* ManageStatisticsCardView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ManageStatisticsCardView.xib; sourceTree = "<group>"; };
8F499B04267CDE530047C1A6 /* ManageStatisticsCardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ManageStatisticsCardView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4598,6 +4604,7 @@
019C9F38258951BC00B26392 /* DiaryEntryType.swift */,
01909881257E675D0065D050 /* DiaryContactPerson.swift */,
BAEFB35D2656BD4700497F79 /* DiaryDayTest.swift */,
8F47CB6A293E4170008D91E5 /* DiaryDaySubmission.swift */,
019C9F2C258951B700B26392 /* ContactPersonEncounter.swift */,
019C9F3F258951C000B26392 /* DiaryLocation.swift */,
019C9F31258951B900B26392 /* LocationVisit.swift */,
Expand Down Expand Up @@ -7448,6 +7455,15 @@
path = __tests__;
sourceTree = "<group>";
};
8F47CB65293E35A2008D91E5 /* StoreV6 */ = {
isa = PBXGroup;
children = (
8F47CB68293E376A008D91E5 /* ContactDiaryMigration5To6.swift */,
8F47CB66293E35C5008D91E5 /* ContactDiaryStoreSchemaV6.swift */,
);
path = StoreV6;
sourceTree = "<group>";
};
8F4B8C5326F8A5CB007620D0 /* _tests_ */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -8307,6 +8323,7 @@
AB6887E725D6754C00907465 /* StoreV3 */,
AB190EE125FF5AC500FBFF0D /* StoreV4 */,
BAEFB3532656A73400497F79 /* StoreV5 */,
8F47CB65293E35A2008D91E5 /* StoreV6 */,
);
path = Store;
sourceTree = "<group>";
Expand Down Expand Up @@ -11473,6 +11490,7 @@
3494D927261DD49100EC532C /* DMPosterGenerationViewModel.swift in Sources */,
3494635227FC937900403F7A /* AntigenTestProfileOverviewEmptyStateViewModel.swift in Sources */,
BA5B7FD526458EF400502087 /* HealthCertificateSimpleTextCell.swift in Sources */,
8F47CB69293E376A008D91E5 /* ContactDiaryMigration5To6.swift in Sources */,
8F5B5C172648CD3800456381 /* HealthCertifiedPersonCellModel.swift in Sources */,
354642F8262E07840004618A /* AccessibleStackView.swift in Sources */,
341320562742B951003E3906 /* TicketValidationCertificateSelectionViewModel.swift in Sources */,
Expand Down Expand Up @@ -12117,6 +12135,7 @@
0138F54D25ECD44300A9B075 /* app_config_ios.pb.swift in Sources */,
5001DE7526E20118004242FA /* VaccinationValueSets.swift in Sources */,
0138F56125ECDC7700A9B075 /* TransmissionRiskValueMapping.swift in Sources */,
8F47CB6B293E4170008D91E5 /* DiaryDaySubmission.swift in Sources */,
8FB7C9282750EF6E0071C98C /* ServiceIdentityDocumentValidationDecoratorError.swift in Sources */,
94EAF87125B6CA9D00BE1F40 /* DeltaOnboardingNewVersionFeatures.swift in Sources */,
2FA9E39324D2F2920030561C /* TestResult.swift in Sources */,
Expand Down Expand Up @@ -12455,6 +12474,7 @@
01F6701225FF79830069C4F9 /* EventCellModel.swift in Sources */,
BA2C88E727FDC61500CE7E1E /* RevocationProvider.swift in Sources */,
BA9BCF6225B0875100DD7974 /* DiaryOverviewDayCellModel.swift in Sources */,
8F47CB67293E35C5008D91E5 /* ContactDiaryStoreSchemaV6.swift in Sources */,
8FEC12242754B6C000C5DADC /* Locator+AllowList.swift in Sources */,
BA0887A6269F43930007B3F3 /* NSMutableAttributedString+Link.swift in Sources */,
DC03798A28EDD51C00E1EE20 /* link_card.pb.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "Warn_light.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -1970,7 +1970,6 @@ Bei ausgeschalteter Hintergrundaktualisierung müssen Sie die App täglich aufru
"TestResultPositive_KeysSubmitted_PrimaryButton" = "Test löschen";

/* Contact Diary*/

/* Error */

"ContactDiary_Overview_Error_Title" = "Fehler";
Expand Down Expand Up @@ -2039,6 +2038,10 @@ Bei ausgeschalteter Hintergrundaktualisierung müssen Sie die App täglich aufru

"ContactDiaray_Overview_Checkin_Low_Risk_In_Brackets" = "(niedriges Risiko)";

/* Submission */

"ContactDiary_Overview_Submission" = "Andere gewarnt";

/* Day */
"ContactDiary_Day_ContactPersonsSegment" = "Personen";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, CoronaWarnAppDelegate, Re
appConfigurationProvider: self.appConfigurationProvider,
restServiceProvider: self.restServiceProvider,
store: self.store,
diaryStore: contactDiaryStore,
eventStore: self.eventStore,
coronaTestService: coronaTestService,
ppacService: ppacService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ class TaskExecutionHandler: ENATaskExecutionDelegate {
appConfigurationProvider: dependencies.appConfigurationProvider,
restServiceProvider: restServiceProvider,
store: dependencies.store,
diaryStore: dependencies.diaryStore,
eventStore: dependencies.eventStore,
coronaTestService: dependencies.coronaTestService,
ppacService: ppacService
Expand Down
2 changes: 2 additions & 0 deletions src/xcode/ENA/ENA/Source/RootCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ class RootCoordinator: NSObject, RequiresAppDependencies, UITabBarControllerDele
appConfigurationProvider: CachedAppConfigurationMock(with: CachedAppConfigurationMock.screenshotConfiguration, store: store),
restServiceProvider: restServiceProvider,
store: store,
diaryStore: contactDiaryStore,
eventStore: eventStore,
coronaTestService: coronaTestService,
ppacService: ppacService
Expand All @@ -449,6 +450,7 @@ class RootCoordinator: NSObject, RequiresAppDependencies, UITabBarControllerDele
appConfigurationProvider: appConfigurationProvider,
restServiceProvider: restServiceProvider,
store: store,
diaryStore: contactDiaryStore,
eventStore: eventStore,
coronaTestService: coronaTestService,
ppacService: ppacService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ class DiaryAddAndEditEntryViewModelTest: CWATestCase {
let emptyDiaryDay = DiaryDay(
dateString: "2020-12-11",
entries: [],
tests: []
tests: [],
submissions: []
)

let store = emptyMockStore()
Expand Down Expand Up @@ -305,7 +306,8 @@ class DiaryAddAndEditEntryViewModelTest: CWATestCase {
let emptyDiaryDay = DiaryDay(
dateString: "2020-12-11",
entries: [],
tests: []
tests: [],
submissions: []
)

let store = emptyMockStore()
Expand Down Expand Up @@ -385,7 +387,8 @@ class DiaryAddAndEditEntryViewModelTest: CWATestCase {
.contactPerson(DiaryContactPerson(id: 3, name: "Pascal Brause", phoneNumber: "123456")),
.contactPerson(DiaryContactPerson(id: 8, name: "Puneet Mahali", emailAddress: "unknown"))
],
tests: []
tests: [],
submissions: []
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class DiaryDayViewModelTest: CWATestCase {
.contactPerson(DiaryContactPerson(id: 8, name: "Puneet Mahali")),
.location(DiaryLocation(id: 1, name: "Bakery", traceLocationId: nil)),
.location(DiaryLocation(id: 0, name: "Supermarket", traceLocationId: nil))
], tests: []
], tests: [], submissions: []
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ struct DiaryDay: Equatable {
init(
dateString: String,
entries: [DiaryEntry],
tests: [DiaryDayTest]
tests: [DiaryDayTest],
submissions: [DiaryDaySubmission]
) {
self.dateString = dateString
self.entries = entries
self.tests = tests
self.submissions = submissions
}

// MARK: - Internal

let dateString: String
let entries: [DiaryEntry]
let tests: [DiaryDayTest]
let submissions: [DiaryDaySubmission]

var selectedEntries: [DiaryEntry] {
entries.filter { $0.isSelected }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//
// 🦠 Corona-Warn-App
//

import Foundation

struct DiaryDaySubmission: Equatable {
let id: Int
let date: String
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class DiaryDayTest: CWATestCase {
let diaryDay = DiaryDay(
dateString: dateString,
entries: entries,
tests: []
tests: [],
submissions: []
)

XCTAssertEqual(diaryDay.dateString, dateString)
Expand Down Expand Up @@ -77,7 +78,8 @@ class DiaryDayTest: CWATestCase {
let diaryDay = DiaryDay(
dateString: dateString,
entries: entries,
tests: []
tests: [],
submissions: []
)

XCTAssertEqual(diaryDay.selectedEntries, [
Expand All @@ -90,7 +92,8 @@ class DiaryDayTest: CWATestCase {
let diaryDay = DiaryDay(
dateString: "2020-12-16",
entries: [],
tests: []
tests: [],
submissions: []
)

XCTAssertEqual(diaryDay.formattedDate, "Mittwoch, 16.12.20")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ final class DiaryOverviewDayCellModel {
var diaryDayTests: [DiaryDayTest] {
return diaryDay.tests
}

var diaryDaySubmissions: [DiaryDaySubmission] {
return diaryDay.submissions
}

func checkInDespription(checkinWithRisk: CheckinWithRisk) -> String {
let checkinName = checkinWithRisk.checkIn.traceLocationDescription
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import UIKit

// swiftlint:disable:next type_body_length
class DiaryOverviewDayTableViewCell: UITableViewCell {

// MARK: - Internal
Expand All @@ -22,6 +23,8 @@ class DiaryOverviewDayTableViewCell: UITableViewCell {
configureTests(cellViewModel)
// should not be clickable with white background
configureCheckinWithRisks(cellViewModel)
// should not be clickable with white background
configureSubmissions(cellViewModel)
// should be clickable with grey background
configureEncounters(cellViewModel)

Expand Down Expand Up @@ -51,6 +54,8 @@ class DiaryOverviewDayTableViewCell: UITableViewCell {
@IBOutlet private weak var exposureHistoryDetailLabel: ENALabel!
// PCR & Antigen Tests
@IBOutlet private weak var testsStackView: UIStackView!
// Exposure submissions
@IBOutlet private weak var submissionsStackView: UIStackView!
// Check-Ins with risk
@IBOutlet private weak var checkinHistoryContainerStackView: UIStackView!
@IBOutlet private weak var checkinHistoryNoticeImageView: UIImageView!
Expand Down Expand Up @@ -195,6 +200,72 @@ class DiaryOverviewDayTableViewCell: UITableViewCell {
}
}

private func configureSubmissions(_ cellViewModel: DiaryOverviewDayCellModel) {
// submissions
submissionsStackView.arrangedSubviews.forEach { $0.removeFromSuperview() }
submissionsStackView.isHidden = cellViewModel.diaryDaySubmissions.isEmpty
if #available(iOS 14.0, *) {
submissionsStackView.backgroundColor = .enaColor(for: .darkBackground)
} else {
submissionsStackView.add(backgroundColor: .enaColor(for: .darkBackground))
}
// Because we set the background color, the border of the underlying view disappears. For this we need some new borders at the left and right.
drawBorders(to: [.left, .right], on: submissionsStackView)

cellViewModel.diaryDaySubmissions.forEach {_ in
let containerView = UIView()
containerView.translatesAutoresizingMaskIntoConstraints = false

let imageView = UIImageView()
imageView.image = UIImage(imageLiteralResourceName: "Warn_light")
NSLayoutConstraint.activate([
imageView.widthAnchor.constraint(equalToConstant: 32),
imageView.heightAnchor.constraint(equalToConstant: 32)
])
let entryLabel = ENALabel()
entryLabel.text = AppStrings.ContactDiary.Overview.submission
entryLabel.adjustsFontForContentSizeCategory = true
entryLabel.style = .body

let horizontalStackView = UIStackView(arrangedSubviews: [imageView, entryLabel])
horizontalStackView.translatesAutoresizingMaskIntoConstraints = false
horizontalStackView.alignment = .center
horizontalStackView.spacing = 15.0
containerView.addSubview(horizontalStackView)

horizontalStackView.addArrangedSubview(imageView)
horizontalStackView.addArrangedSubview(entryLabel)

drawBorders(to: [.top], on: submissionsStackView)
submissionsStackView.addArrangedSubview(containerView)

let separatorLine = UIView()
separatorLine.backgroundColor = .enaColor(for: .hairline)
separatorLine.translatesAutoresizingMaskIntoConstraints = false
submissionsStackView.addSubview(separatorLine)

// Draw the separator line from leading to trailing of the submissionsStackView
NSLayoutConstraint.activate([
separatorLine.heightAnchor.constraint(equalToConstant: 1),
separatorLine.leadingAnchor.constraint(equalTo: submissionsStackView.leadingAnchor),
separatorLine.trailingAnchor.constraint(equalTo: submissionsStackView.trailingAnchor),
separatorLine.topAnchor.constraint(equalTo: submissionsStackView.topAnchor, constant: 0)
])

// Draw the containerView line from leading to trailing of the submissionsStackView
NSLayoutConstraint.activate(
[
containerView.topAnchor.constraint(equalTo: submissionsStackView.topAnchor),
horizontalStackView.leadingAnchor.constraint(equalTo: containerView.leadingAnchor),
horizontalStackView.topAnchor.constraint(equalTo: containerView.topAnchor, constant: 12.0),
horizontalStackView.trailingAnchor.constraint(equalTo: containerView.trailingAnchor),
horizontalStackView.bottomAnchor.constraint(equalTo: containerView.bottomAnchor, constant: -12.0)

]
)
}
}

// swiftlint:disable:next cyclomatic_complexity
private func configureEncounters(_ cellViewModel: DiaryOverviewDayCellModel) {
encountersVisitsContainerStackView.arrangedSubviews.forEach { $0.removeFromSuperview() }
Expand Down
Loading

0 comments on commit 239576d

Please sign in to comment.