generated from StanfordBDHG/SwiftPackageTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allowing to identify multiple consent forms during onboarding via a n…
…ew parameter "identifier" added to OnboardingConsentView and OnboardingConstraint.store(...). The parameter can be optionally specified when using an OnboardingConsentView to distinguish multiple consent forms when storing. If not specified in OnboardingConsentView, the default value „DefaultConsentDocument“ is set. UITests/TestApp has been changed accordingly to test the new functionality of having multiple (in this case two) consent forms. OnboardingConsentMarkdownTestView and OnboardingConsentMarkdownRenderingView have been renamed to OnboardingFirstConsentMarkdownRenderingView and OnboardingFirstConsentMarkdownRenderingView accordingly. Views for a second consent form were added (OnboardingSecondConsentMarkdownRenderingView and -TestView). ExampleStandard has been changed to distinguish the two documents based on their identifiers ("FirstConsentDocument" and "SecondConsentDocument") during store and loadConsentDocument.
- Loading branch information
Showing
14 changed files
with
240 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
Tests/UITests/TestApp/Views/OnboardingSecondConsentMarkdownRenderingView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// | ||
// This source file is part of the Stanford Spezi open-source project | ||
// | ||
// SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
import PDFKit | ||
import SpeziOnboarding | ||
import SpeziViews | ||
import SwiftUI | ||
|
||
|
||
struct OnboardingSecondConsentMarkdownRenderingView: View { | ||
Check warning on line 15 in Tests/UITests/TestApp/Views/OnboardingSecondConsentMarkdownRenderingView.swift GitHub Actions / Build and Test UI Tests iOS (Debug, TestApp-iOS.xcresult, TestApp-iOS.xcresult) / Test using xcodebuild or run fastlane
|
||
@Environment(OnboardingNavigationPath.self) private var path | ||
@Environment(ExampleStandard.self) private var standard | ||
@State var exportedConsent: PDFDocument? | ||
|
||
private var documentIdentifier = "SecondConsentDocument" | ||
|
||
var body: some View { | ||
VStack { | ||
if (exportedConsent?.pageCount ?? 0) == 0 { | ||
Circle() | ||
.fill(Color.red) | ||
.frame(width: 200, height: 200) | ||
.overlay( | ||
Text("Second Consent PDF rendering doesn't exist") | ||
.foregroundColor(.white) | ||
.multilineTextAlignment(.center) | ||
.padding() | ||
) | ||
} else { | ||
Circle() | ||
.fill(Color.green) | ||
.frame(width: 200, height: 200) | ||
.overlay( | ||
Text("Second Consent PDF rendering exists") | ||
.foregroundColor(.white) | ||
.multilineTextAlignment(.center) | ||
.padding() | ||
) | ||
} | ||
|
||
Button { | ||
path.nextStep() | ||
} label: { | ||
Text("Next") | ||
} | ||
.buttonStyle(.borderedProminent) | ||
} | ||
.padding() | ||
#if !os(macOS) | ||
.navigationBarTitleDisplayMode(.inline) | ||
#endif | ||
.task { | ||
self.exportedConsent = try? await standard.loadConsentDocument(identifier: documentIdentifier) | ||
// Reset OnboardingDataSource | ||
await standard.store(consent: .init(), identifier: documentIdentifier) | ||
} | ||
} | ||
} | ||
|
||
|
||
#if DEBUG | ||
struct OnboardingSecondConsentMarkdownRenderingView_Previews: PreviewProvider { | ||
static var standard: OnboardingDataSource = .init() | ||
|
||
|
||
static var previews: some View { | ||
OnboardingStack(startAtStep: OnboardingSecondConsentMarkdownRenderingView.self) { | ||
for onboardingView in OnboardingFlow.previewSimulatorViews { | ||
onboardingView | ||
.environment(standard) | ||
} | ||
} | ||
} | ||
} | ||
#endif |
46 changes: 46 additions & 0 deletions
46
Tests/UITests/TestApp/Views/OnboardingSecondConsentMarkdownTestView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// This source file is part of the Stanford Spezi open-source project | ||
// | ||
// SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
import SpeziOnboarding | ||
import SpeziViews | ||
import SwiftUI | ||
|
||
|
||
struct OnboardingSecondConsentMarkdownTestView: View { | ||
@Environment(OnboardingNavigationPath.self) private var path | ||
|
||
private var documentIdentifier = "SecondConsentDocument" | ||
|
||
|
||
var body: some View { | ||
OnboardingConsentView( | ||
markdown: { | ||
Data("This is the second *markdown* **example**".utf8) | ||
}, | ||
action: { | ||
path.nextStep() | ||
}, | ||
title: "Second Consent", | ||
identifier: documentIdentifier, | ||
exportConfiguration: .init(paperSize: .dinA4, includingTimestamp: true) | ||
) | ||
} | ||
} | ||
|
||
|
||
#if DEBUG | ||
struct OnboardingSecondConsentMarkdownTestView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
OnboardingStack(startAtStep: OnboardingSecondConsentMarkdownTestView.self) { | ||
for onboardingView in OnboardingFlow.previewSimulatorViews { | ||
onboardingView | ||
} | ||
} | ||
} | ||
} | ||
#endif |
Oops, something went wrong.