Skip to content

Commit

Permalink
Add consent document viewer to profile screen
Browse files Browse the repository at this point in the history
  • Loading branch information
vishnuravi committed Jun 26, 2024
1 parent 22e67a6 commit 3099fd7
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 11 deletions.
18 changes: 9 additions & 9 deletions LifeSpace.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -768,9 +768,9 @@
CODE_SIGN_ENTITLEMENTS = "LifeSpace/Supporting Files/LifeSpace.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4;
CURRENT_PROJECT_VERSION = 5;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = B2Q3T3P8HP;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "LifeSpace/Supporting Files/Info.plist";
Expand Down Expand Up @@ -832,7 +832,7 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 637867499T;
DEVELOPMENT_TEAM = "";
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.odden.strokecoguitests;
Expand Down Expand Up @@ -972,9 +972,9 @@
CODE_SIGN_ENTITLEMENTS = "LifeSpace/Supporting Files/LifeSpace.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4;
CURRENT_PROJECT_VERSION = 5;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = B2Q3T3P8HP;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "LifeSpace/Supporting Files/Info.plist";
Expand Down Expand Up @@ -1019,9 +1019,9 @@
CODE_SIGN_ENTITLEMENTS = "LifeSpace/Supporting Files/LifeSpace.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4;
CURRENT_PROJECT_VERSION = 5;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = B2Q3T3P8HP;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "LifeSpace/Supporting Files/Info.plist";
Expand Down Expand Up @@ -1102,7 +1102,7 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 637867499T;
DEVELOPMENT_TEAM = "";
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.odden.strokecoguitests;
Expand All @@ -1120,7 +1120,7 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 637867499T;
DEVELOPMENT_TEAM = "";
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.odden.strokecoguitests;
Expand Down
47 changes: 45 additions & 2 deletions LifeSpace/Account/AccountSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// SPDX-License-Identifier: MIT
//

import PDFKit
import SpeziAccount
import SwiftUI

Expand All @@ -19,12 +20,26 @@ struct AccountSheet: View {
@State var isInSetup = false
@State var overviewIsEditing = false


//swiftlint:disable closure_body_length

Check failure on line 23 in LifeSpace/Account/AccountSheet.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint

Comment Spacing Violation: Prefer at least one space after slashes for comments (comment_spacing)
var body: some View {
NavigationStack {
ZStack {
if account.signedIn && !isInSetup {
AccountOverview(isEditing: $overviewIsEditing) {
AccountOverview(isEditing: $overviewIsEditing

Check failure on line 28 in LifeSpace/Account/AccountSheet.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint

Multiline Arguments Brackets Violation: Multiline arguments should have their surrounding brackets in a new line (multiline_arguments_brackets)
) {
List {
Section(header: Text("Study ID")) {
Text("\(getStudyID())")
}
Section(header: Text("Documents")) {
NavigationLink(destination: PDFViewWrapper(url: getDocumentURL(for: "consent"))) {
Text("View Consent Document")
}
NavigationLink(destination: PDFViewWrapper(url: getDocumentURL(for: "hipaaAuthorization"))) {
Text("View HIPAA Authorization")
}
}
}
}
.onDisappear {
overviewIsEditing = false
Expand Down Expand Up @@ -61,9 +76,37 @@ struct AccountSheet: View {
}
}
}

func getStudyID() -> String {
UserDefaults.standard.string(forKey: StorageKeys.studyID) ?? "unknownStudyID"
}

func getDocumentURL(for fileName: String) -> URL {
let studyID = getStudyID()
let filename = "\(studyID)_\(fileName).pdf"

let fileManager = FileManager.default
let documentsURL = fileManager.urls(for: .documentDirectory, in: .userDomainMask).first!

Check failure on line 89 in LifeSpace/Account/AccountSheet.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint

Force Unwrapping Violation: Force unwrapping should be avoided (force_unwrapping)
let fileURL = documentsURL.appendingPathComponent(filename)

return fileURL
}
}


struct PDFViewWrapper: UIViewRepresentable {
let url: URL

func makeUIView(context: Context) -> PDFView {
let pdfView = PDFView()
pdfView.document = PDFDocument(url: url)
pdfView.autoScales = true
return pdfView
}

func updateUIView(_ uiView: PDFView, context: Context) {}
}

#if DEBUG
#Preview("AccountSheet") {
let details = AccountDetails.Builder()
Expand Down
15 changes: 15 additions & 0 deletions LifeSpace/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"sourceLanguage" : "en",
"strings" : {
"%@" : {

},
"ACCOUNT_NEXT" : {
"localizations" : {
"en" : {
Expand Down Expand Up @@ -162,6 +165,9 @@
}
}
}
},
"Documents" : {

},
"ERROR" : {
"localizations" : {
Expand Down Expand Up @@ -520,6 +526,9 @@
}
}
}
},
"Study ID" : {

},
"STUDYID_ACTION_BUTTON" : {
"localizations" : {
Expand Down Expand Up @@ -650,6 +659,12 @@
}
}
}
},
"View Consent Document" : {

},
"View HIPAA Authorization" : {

},
"WELCOME_AREA1_DESCRIPTION" : {
"localizations" : {
Expand Down
33 changes: 33 additions & 0 deletions LifeSpace/Resources/studyIDs.csv
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,36 @@
333333
444444
555555
123803
173060
201938
208495
208914
211142
224547
292795
422555
440309
457982
491854
513003
606647
612922
628002
683401
703611
712567
761295
764367
853261
865802
900779
907218
913939
947160
958806
966990
976512
481434
689724
391194

0 comments on commit 3099fd7

Please sign in to comment.