Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load Date of Enrollment From the Firebase Instance #83

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
3 changes: 2 additions & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ jobs:
contents: read
codeql:
name: CodeQL
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
permissions:
security-events: write
actions: read
contents: read
with:
codeql: true
fastlanelane: codeql
xcodeversion: "16.1" # Temporary workaround for: https://github.com/actions/runner-images/issues/11335. Remove when resolved.
pylint:
name: PyLint
runs-on: ubuntu-latest
Expand Down
4 changes: 0 additions & 4 deletions .periphery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,3 @@
project: PAWS.xcodeproj
schemes:
- PAWS
targets:
- PAWS
- PAWSTests
- PAWSUITests
30 changes: 17 additions & 13 deletions PAWS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
653A2551283387FE005D4D48 /* PAWS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 653A2550283387FE005D4D48 /* PAWS.swift */; };
653A255528338800005D4D48 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 653A255428338800005D4D48 /* Assets.xcassets */; };
653A256228338800005D4D48 /* PAWSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 653A256128338800005D4D48 /* PAWSTests.swift */; };
65A0437E2CF3E43400B44621 /* DateOfEnrollment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65A0437D2CF3E43400B44621 /* DateOfEnrollment.swift */; };
9733CFC62A8066DE001B7ABC /* SpeziOnboarding in Frameworks */ = {isa = PBXBuildFile; productRef = 2FE5DC8029EDD91D004B9AB4 /* SpeziOnboarding */; };
9739A0C62AD7B5730084BEA5 /* FirebaseStorage in Frameworks */ = {isa = PBXBuildFile; productRef = 9739A0C52AD7B5730084BEA5 /* FirebaseStorage */; };
97D73D6A2AD860AD00B47FA0 /* SpeziFirebaseStorage in Frameworks */ = {isa = PBXBuildFile; productRef = 97D73D692AD860AD00B47FA0 /* SpeziFirebaseStorage */; };
Expand Down Expand Up @@ -141,6 +142,7 @@
653A256128338800005D4D48 /* PAWSTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PAWSTests.swift; sourceTree = "<group>"; };
653A256728338800005D4D48 /* PAWSUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PAWSUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
653A258928339462005D4D48 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
65A0437D2CF3E43400B44621 /* DateOfEnrollment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateOfEnrollment.swift; sourceTree = "<group>"; };
A9720E422ABB68CC00872D23 /* AccountSetupHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountSetupHeader.swift; sourceTree = "<group>"; };
A9DFE8A82ABE551400428242 /* AccountButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountButton.swift; sourceTree = "<group>"; };
A9FE7ACF2AA39BAB0077B045 /* AccountSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountSheet.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -380,6 +382,7 @@
A9FE7ACF2AA39BAB0077B045 /* AccountSheet.swift */,
A9720E422ABB68CC00872D23 /* AccountSetupHeader.swift */,
A9DFE8A82ABE551400428242 /* AccountButton.swift */,
65A0437D2CF3E43400B44621 /* DateOfEnrollment.swift */,
);
path = Account;
sourceTree = "<group>";
Expand Down Expand Up @@ -592,6 +595,7 @@
2FCC1DC92B6A258A00C686BE /* PAWSScheduler.swift in Sources */,
B2433E1D2BCF60C800D7C798 /* Contact+PersonNameComponents.swift in Sources */,
2FFD22FF2B59B158005DD268 /* StudyDescription.swift in Sources */,
65A0437E2CF3E43400B44621 /* DateOfEnrollment.swift in Sources */,
2FCC1DC52B6A1F0600C686BE /* ECGRecording.swift in Sources */,
2F5E32BD297E05EA003432F8 /* PAWSDelegate.swift in Sources */,
A9FE7AD02AA39BAB0077B045 /* AccountSheet.swift in Sources */,
Expand Down Expand Up @@ -990,7 +994,7 @@
};
2F49B7742980407B00BCB272 /* XCRemoteSwiftPackageReference "Spezi" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/StanfordSpezi/Spezi";
repositoryURL = "https://github.com/StanfordSpezi/Spezi.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.8.0;
Expand All @@ -1001,23 +1005,23 @@
repositoryURL = "https://github.com/StanfordBDHG/HealthKitOnFHIR.git";
requirement = {
kind = upToNextMinorVersion;
minimumVersion = 0.2.11;
minimumVersion = 0.2.13;
};
};
2FCC1DCE2B6A2CE000C686BE /* XCRemoteSwiftPackageReference "SwiftLint" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/realm/SwiftLint.git";
requirement = {
kind = upToNextMinorVersion;
minimumVersion = 0.57.0;
minimumVersion = 0.58.2;
};
};
2FE5DC6229EDD883004B9AB4 /* XCRemoteSwiftPackageReference "SpeziAccount" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/StanfordSpezi/SpeziAccount.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 2.1.0;
minimumVersion = 2.1.2;
};
};
2FE5DC6529EDD894004B9AB4 /* XCRemoteSwiftPackageReference "SpeziContact" */ = {
Expand All @@ -1041,55 +1045,55 @@
repositoryURL = "https://github.com/StanfordSpezi/SpeziFirebase.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 2.0.0;
minimumVersion = 2.0.1;
};
};
2FE5DC8829EDD972004B9AB4 /* XCRemoteSwiftPackageReference "SpeziStorage" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/StanfordSpezi/SpeziStorage.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.1.2;
minimumVersion = 1.2.2;
};
};
2FE5DC8D29EDD980004B9AB4 /* XCRemoteSwiftPackageReference "SpeziViews" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/StanfordSpezi/SpeziViews.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.2.1;
minimumVersion = 1.8.0;
};
};
2FE5DC9029EDD9C3004B9AB4 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/firebase/firebase-ios-sdk.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 11.5.0;
minimumVersion = 11.7.0;
};
};
2FE5DC9729EDD9D9004B9AB4 /* XCRemoteSwiftPackageReference "XCTestExtensions" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/StanfordBDHG/XCTestExtensions.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.1.0;
minimumVersion = 1.1.1;
};
};
2FE5DC9A29EDD9EF004B9AB4 /* XCRemoteSwiftPackageReference "XCTHealthKit" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/StanfordBDHG/XCTHealthKit.git";
requirement = {
kind = upToNextMinorVersion;
minimumVersion = 0.3.5;
kind = upToNextMajorVersion;
minimumVersion = 1.0.0;
};
};
5661551B2AB8384200209B80 /* XCRemoteSwiftPackageReference "swift-package-list" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/FelixHerrmann/swift-package-list";
repositoryURL = "https://github.com/FelixHerrmann/swift-package-list.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 4.1.0;
minimumVersion = 4.4.2;
};
};
65B012C52CEB030E000AA72D /* XCRemoteSwiftPackageReference "SpeziLicense" */ = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "35b86c0bac11027e29970c00a506ec75d395fa5f014085f7123cbabeb12abf7b",
"originHash" : "6b3bc6a911d19827584cac47f26bc578e7c764644527a4af2a344f9caea16df7",
"pins" : [
{
"identity" : "abseil-cpp-binary",
Expand Down Expand Up @@ -33,8 +33,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/krzyzanowskim/CryptoSwift.git",
"state" : {
"revision" : "678d442c6f7828def400a70ae15968aef67ef52d",
"version" : "1.8.3"
"revision" : "729e01bc9b9dab466ac85f21fb9ee2bc1c61b258",
"version" : "1.8.4"
}
},
{
Expand All @@ -51,17 +51,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/firebase-ios-sdk.git",
"state" : {
"revision" : "dbdfdc44bee8b8e4eaa5ec27eb12b9338f3f2bc1",
"version" : "11.5.0"
"revision" : "0d885d28250fb1196b614bc9455079b75c531f72",
"version" : "11.7.0"
}
},
{
"identity" : "googleappmeasurement",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleAppMeasurement.git",
"state" : {
"revision" : "4f234bcbdae841d7015258fbbf8e7743a39b8200",
"version" : "11.4.0"
"revision" : "be0881ff728eca210ccb628092af400c086abda3",
"version" : "11.7.0"
}
},
{
Expand Down Expand Up @@ -105,8 +105,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordBDHG/HealthKitOnFHIR.git",
"state" : {
"revision" : "87a9257e6fa37407f3437e4a0bf21dd09a4ea7c5",
"version" : "0.2.11"
"revision" : "c898c0bace660ecae37fc682d629f7883f92e700",
"version" : "0.2.13"
}
},
{
Expand Down Expand Up @@ -168,8 +168,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/SpeziAccount.git",
"state" : {
"revision" : "0e4dcc7d3284b439b17fae621c5c6e73d9213696",
"version" : "2.1.0"
"revision" : "de427909c99aa0575f6d12620f3a8098d28b8999",
"version" : "2.1.2"
}
},
{
Expand All @@ -186,8 +186,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/SpeziFirebase.git",
"state" : {
"revision" : "7c6829624884f6f1d700e0316b2580b39d3b0c5f",
"version" : "2.0.0"
"revision" : "5dd57f9de42c02d6a94f3af4d8cf3d9b81ec6661",
"version" : "2.0.1"
}
},
{
Expand Down Expand Up @@ -240,17 +240,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/SpeziStorage.git",
"state" : {
"revision" : "0f4a54430e51f82d29da63a7ce5f61bad7dfb9cd",
"version" : "1.2.1"
"revision" : "1dc69e5fd6f02e87d00da9502176d25ef3f5795f",
"version" : "1.2.2"
}
},
{
"identity" : "speziviews",
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/SpeziViews.git",
"state" : {
"revision" : "f87514406bb57ae67d0040eec5454fff55104143",
"version" : "1.7.0"
"revision" : "69b085705f2af4c5dfe93278a228c12caa6c3379",
"version" : "1.8.0"
}
},
{
Expand Down Expand Up @@ -285,8 +285,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/FelixHerrmann/swift-package-list",
"state" : {
"revision" : "26732b1cf7e422cb330a1e24420394752a14b059",
"version" : "4.4.1"
"revision" : "5e954ec39ce2374ff28a38224fd4e6bba7c57cdc",
"version" : "4.4.2"
}
},
{
Expand All @@ -303,17 +303,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/swiftlang/swift-syntax.git",
"state" : {
"revision" : "515f79b522918f83483068d99c68daeb5116342d",
"version" : "600.0.0-prerelease-2024-08-14"
"revision" : "cb53fa1bd3219b0b23ded7dfdd3b2baff266fd25",
"version" : "600.0.0"
}
},
{
"identity" : "swiftlint",
"kind" : "remoteSourceControl",
"location" : "https://github.com/realm/SwiftLint.git",
"state" : {
"revision" : "168fb98ed1f3e343d703ecceaf518b6cf565207b",
"version" : "0.57.0"
"revision" : "eba420f77846e93beb98d516b225abeb2fef4ca2",
"version" : "0.58.2"
}
},
{
Expand All @@ -339,17 +339,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordBDHG/XCTestExtensions.git",
"state" : {
"revision" : "5379d70249cae926927105bfb6686770f03ee5b9",
"version" : "1.1.0"
"revision" : "d3a128997ddc3f958cbd6a534d71814f42eed1b3",
"version" : "1.1.1"
}
},
{
"identity" : "xcthealthkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordBDHG/XCTHealthKit",
"state" : {
"revision" : "6e9344a2d632b801d94fe3bbd1d891817e032103",
"version" : "0.3.5"
"revision" : "5b6bebe83e2aeef49bb194795dc896f948a1c164",
"version" : "1.0.0"
}
},
{
Expand Down
7 changes: 6 additions & 1 deletion PAWS/Account/AccountSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
@Environment(Account.self) private var account
@Environment(\.accountRequired) var accountRequired

// periphery:ignore - Uses @AppStorage
@AppStorage(StorageKeys.healthKitStartDate) var healthKitStartDate: Date?

@State var isInSetup = false


Expand All @@ -32,7 +35,9 @@
}
}
} else {
AccountSetup { _ in
AccountSetup { details in
healthKitStartDate = details.dateOfEnrollment

Check warning on line 40 in PAWS/Account/AccountSheet.swift

View check run for this annotation

Codecov / codecov/patch

PAWS/Account/AccountSheet.swift#L39-L40

Added lines #L39 - L40 were not covered by tests
dismiss() // we just signed in, dismiss the account setup sheet
} header: {
AccountSetupHeader()
Expand Down
68 changes: 68 additions & 0 deletions PAWS/Account/DateOfEnrollment.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//
// This source file is part of the PAWS application based on the Stanford Spezi Template Application project
//
// SPDX-FileCopyrightText: 2023 Stanford University
//
// SPDX-License-Identifier: MIT
//

import Foundation
import SpeziAccount
import SpeziViews
import SwiftUI


// swiftlint:disable file_types_order
private struct DisplayView: DataDisplayView {
private let value: Date

@Environment(\.locale) private var locale

private var formatStyle: Date.FormatStyle {
.init()
.locale(locale)
.year(.defaultDigits)
.month(locale.identifier == "en_US" ? .abbreviated : .defaultDigits)
.day(.defaultDigits)
}

var body: some View {
ListRow(AccountKeys.dateOfEnrollment.name) {
Text(value.formatted(formatStyle))
}
}

init(_ value: Date) {
self.value = value
}
}


private struct EntryView: DataEntryView {
@Binding private var value: Date

var body: some View {
DisplayView(value)
}

init(_ value: Binding<Date>) {
self._value = value
}
}

extension AccountDetails {
/// The date of birth of a user.
@AccountKey(
name: LocalizedStringResource("Date of Enrollment"),
category: .other,
as: Date.self,
initial: .empty(Date()),
displayView: DisplayView.self,
entryView: EntryView.self
)
public var dateOfEnrollment: Date? // swiftlint:disable:this attributes
}


@KeyEntry(\.dateOfEnrollment)
extension AccountKeys {}
Loading
Loading