diff --git a/surveys-example.xcodeproj/project.pbxproj b/surveys-example.xcodeproj/project.pbxproj index 8f9ad8e..91b7fc3 100644 --- a/surveys-example.xcodeproj/project.pbxproj +++ b/surveys-example.xcodeproj/project.pbxproj @@ -19,6 +19,7 @@ F56255B32C1A1EF900BF163B /* ResearchKitActiveTask.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = F56255AE2C1A1E7E00BF163B /* ResearchKitActiveTask.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; F56255B42C1A1EF900BF163B /* ResearchKitUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F56255AC2C1A1E7E00BF163B /* ResearchKitUI.framework */; }; F56255B52C1A1EF900BF163B /* ResearchKitUI.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = F56255AC2C1A1E7E00BF163B /* ResearchKitUI.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F59F9B402C1A303B0083C2E9 /* ConsentManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = F59F9B3F2C1A303B0083C2E9 /* ConsentManager.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -78,6 +79,7 @@ F56255982C1A1DF200BF163B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; F562559A2C1A1DF200BF163B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; F56255A02C1A1E7E00BF163B /* ResearchKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ResearchKit.xcodeproj; path = "../../../../Downloads/ResearchKit-main/ResearchKit.xcodeproj"; sourceTree = ""; }; + F59F9B3F2C1A303B0083C2E9 /* ConsentManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConsentManager.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -116,6 +118,7 @@ isa = PBXGroup; children = ( F562558C2C1A1DF000BF163B /* AppDelegate.swift */, + F59F9B3F2C1A303B0083C2E9 /* ConsentManager.swift */, F562558E2C1A1DF000BF163B /* SceneDelegate.swift */, F56255902C1A1DF000BF163B /* ViewController.swift */, F56255922C1A1DF000BF163B /* Main.storyboard */, @@ -253,6 +256,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + F59F9B402C1A303B0083C2E9 /* ConsentManager.swift in Sources */, F56255912C1A1DF000BF163B /* ViewController.swift in Sources */, F562558D2C1A1DF000BF163B /* AppDelegate.swift in Sources */, F562558F2C1A1DF000BF163B /* SceneDelegate.swift in Sources */, diff --git a/surveys-example/Assets.xcassets/pcie-logo.imageset/Contents.json b/surveys-example/Assets.xcassets/pcie-logo.imageset/Contents.json new file mode 100644 index 0000000..00696bc --- /dev/null +++ b/surveys-example/Assets.xcassets/pcie-logo.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "pcie-logo.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/surveys-example/Assets.xcassets/pcie-logo.imageset/pcie-logo.png b/surveys-example/Assets.xcassets/pcie-logo.imageset/pcie-logo.png new file mode 100644 index 0000000..f8d3d9b Binary files /dev/null and b/surveys-example/Assets.xcassets/pcie-logo.imageset/pcie-logo.png differ diff --git a/surveys-example/Base.lproj/Main.storyboard b/surveys-example/Base.lproj/Main.storyboard index 25a7638..173e418 100644 --- a/surveys-example/Base.lproj/Main.storyboard +++ b/surveys-example/Base.lproj/Main.storyboard @@ -1,24 +1,68 @@ - + + - + + + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/surveys-example/ConsentManager.swift b/surveys-example/ConsentManager.swift new file mode 100644 index 0000000..2a37123 --- /dev/null +++ b/surveys-example/ConsentManager.swift @@ -0,0 +1,79 @@ +// +// ConsentManager.swift +// surveys-example +// +// Created by Juan David López Regalado on 12/06/24. +// + +import Foundation +import UIKit +import ResearchKit + +class ConsentManager{ + static let shared = ConsentManager() + + func createConsentTask() -> ORKTask{ + + // Pagina de Welcome + let welcomeStep = ORKInstructionStep(identifier: "consentWelcomeInstructionStep") + welcomeStep.title = "Welcome!" + welcomeStep.iconImage = UIImage(systemName: "hand.wave") + welcomeStep.detailText = "Thank you for being part of the biomarker project aimed at determining the level of sedentary lifestyle. However, before accepting, please read the next part." // explain the consent + + let sign = ORKInstructionStep(identifier: "signAccept") + sign.title = "Please Sign if you Accept" + + + // Pagina del before you join + let beforeYouJoin = ORKInstructionStep(identifier: "informedConsentInstructionStep") + beforeYouJoin.iconImage = UIImage(systemName: "doc.text.magnifyinglass") + beforeYouJoin.title = "Before You Join" + + let sharingHealthDataBodyItem = ORKBodyItem(text: "The study will ask you to share some of your Health data.", + detailText: nil, + image: UIImage(systemName: "heart.fill"), + learnMoreItem: nil, + bodyItemStyle: .image) + + let completingTasksBodyItem = ORKBodyItem(text: "You will be asked to complete various tasks over the duration of the study.", + detailText: nil, + image: UIImage(systemName: "checkmark.circle.fill"), + learnMoreItem: nil, + bodyItemStyle: .image) + + let signatureBodyItem = ORKBodyItem(text: "Before joining, we will ask you to sign an informed consent document.", + detailText: nil, + image: UIImage(systemName: "signature"), + learnMoreItem: nil, + bodyItemStyle: .image) + + let secureDataBodyItem = ORKBodyItem(text: "Your data is kept private and secure.", + detailText: nil, + image: UIImage(systemName: "lock.fill"), + learnMoreItem: nil, + bodyItemStyle: .image) + + beforeYouJoin.bodyItems = [ + sharingHealthDataBodyItem, + completingTasksBodyItem, + signatureBodyItem, + secureDataBodyItem + ] + + + let instructionSteps = [sign] + + let webViewStep = ORKWebViewStep(identifier: "WebViewStepIdentifier", instructionSteps:instructionSteps) + webViewStep.showSignatureAfterContent = true + + + + let task = ORKOrderedTask(identifier: "ConsentTask", steps: [welcomeStep, beforeYouJoin, webViewStep /*other steps*/]) + return task + + + } + + + +} diff --git a/surveys-example/ViewController.swift b/surveys-example/ViewController.swift index 9792416..67eef33 100644 --- a/surveys-example/ViewController.swift +++ b/surveys-example/ViewController.swift @@ -7,14 +7,29 @@ import UIKit import ResearchKit +import ResearchKitUI -class ViewController: UIViewController { +class ViewController: UIViewController, ORKTaskViewControllerDelegate { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. } + + @IBAction func startSurveyTapped(_ sender: Any) { + let consentTask = ConsentManager.shared.createConsentTask() + let taskViewController = ORKTaskViewController(task: consentTask, taskRun: nil) + + taskViewController.delegate = self + present(taskViewController,animated: true, completion: nil) + } + + func taskViewController(_ taskViewController: ORKTaskViewController, didFinishWith reason: ORKTaskFinishReason, error: (any Error)?) { + taskViewController.dismiss(animated: true, completion: nil) + } + + }