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

Backend data type definition & Frontend user input data UI #5

Merged
merged 22 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions NeutroFeverGuard.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@
A9D83F962B083794000D0C78 /* SpeziFirebaseAccountStorage in Frameworks */ = {isa = PBXBuildFile; productRef = A9D83F952B083794000D0C78 /* SpeziFirebaseAccountStorage */; };
A9DFE8A92ABE551400428242 /* AccountButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9DFE8A82ABE551400428242 /* AccountButton.swift */; };
A9FE7AD02AA39BAB0077B045 /* AccountSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9FE7ACF2AA39BAB0077B045 /* AccountSheet.swift */; };
C49EC8342D501C62005C3495 /* DataType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C49EC8332D501C5C005C3495 /* DataType.swift */; };
C49EC8362D501FB9005C3495 /* DataError.swift in Sources */ = {isa = PBXBuildFile; fileRef = C49EC8352D501FB2005C3495 /* DataError.swift */; };
C49EC8382D5026EE005C3495 /* DataTypeTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C49EC8372D5026EE005C3495 /* DataTypeTest.swift */; };
C49EC8402D5033F9005C3495 /* AddDataView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C49EC83F2D5033F9005C3495 /* AddDataView.swift */; };
C49EC8532D5038AC005C3495 /* DataInputForm.swift in Sources */ = {isa = PBXBuildFile; fileRef = C49EC8522D5038AC005C3495 /* DataInputForm.swift */; };
C4C0A78F2D518DBC00F37EEC /* HelperFunc.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4C0A78E2D518DB500F37EEC /* HelperFunc.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -131,6 +137,12 @@
A9A3DCC72C75CB9A00FC9B69 /* FirebaseConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FirebaseConfiguration.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>"; };
C49EC8332D501C5C005C3495 /* DataType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataType.swift; sourceTree = "<group>"; };
C49EC8352D501FB2005C3495 /* DataError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataError.swift; sourceTree = "<group>"; };
C49EC8372D5026EE005C3495 /* DataTypeTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataTypeTest.swift; sourceTree = "<group>"; };
C49EC83F2D5033F9005C3495 /* AddDataView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddDataView.swift; sourceTree = "<group>"; };
C49EC8522D5038AC005C3495 /* DataInputForm.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataInputForm.swift; sourceTree = "<group>"; };
C4C0A78E2D518DB500F37EEC /* HelperFunc.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HelperFunc.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -276,6 +288,11 @@
653A254F283387FE005D4D48 /* NeutroFeverGuard */ = {
isa = PBXGroup;
children = (
C4C0A78E2D518DB500F37EEC /* HelperFunc.swift */,
C49EC83F2D5033F9005C3495 /* AddDataView.swift */,
C49EC8522D5038AC005C3495 /* DataInputForm.swift */,
C49EC8352D501FB2005C3495 /* DataError.swift */,
C49EC8332D501C5C005C3495 /* DataType.swift */,
2FC975A72978F11A00BA99FE /* HomeView.swift */,
653A2550283387FE005D4D48 /* NeutroFeverGuard.swift */,
2F5E32BC297E05EA003432F8 /* NeutroFeverGuardDelegate.swift */,
Expand All @@ -297,6 +314,7 @@
isa = PBXGroup;
children = (
653A256128338800005D4D48 /* NeutroFeverGuardTests.swift */,
C49EC8372D5026EE005C3495 /* DataTypeTest.swift */,
);
path = NeutroFeverGuardTests;
sourceTree = "<group>";
Expand Down Expand Up @@ -528,6 +546,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C49EC8532D5038AC005C3495 /* DataInputForm.swift in Sources */,
2FE5DC4129EDD7EE004B9AB4 /* StorageKeys.swift in Sources */,
2FE5DCB129EE6107004B9AB4 /* AccountOnboarding.swift in Sources */,
2FE5DC3A29EDD7CA004B9AB4 /* Welcome.swift in Sources */,
Expand All @@ -543,14 +562,18 @@
A9720E432ABB68CC00872D23 /* AccountSetupHeader.swift in Sources */,
2FE5DC4029EDD7EE004B9AB4 /* FeatureFlags.swift in Sources */,
2F4E23832989D51F0013F3D9 /* NeutroFeverGuardTestingSetup.swift in Sources */,
C4C0A78F2D518DBC00F37EEC /* HelperFunc.swift in Sources */,
C49EC8402D5033F9005C3495 /* AddDataView.swift in Sources */,
A98FF2B12CD131F500DFC949 /* EventView.swift in Sources */,
C49EC8342D501C62005C3495 /* DataType.swift in Sources */,
2FE5DC5329EDD7FA004B9AB4 /* Bundle+Questionnaire.swift in Sources */,
2F5E32BD297E05EA003432F8 /* NeutroFeverGuardDelegate.swift in Sources */,
2FE5DC5229EDD7FA004B9AB4 /* NeutroFeverGuardScheduler.swift in Sources */,
A9FE7AD02AA39BAB0077B045 /* AccountSheet.swift in Sources */,
653A2551283387FE005D4D48 /* NeutroFeverGuard.swift in Sources */,
2FE5DC3629EDD7CA004B9AB4 /* HealthKitPermissions.swift in Sources */,
2F65B44E2A3B8B0600A36932 /* NotificationPermissions.swift in Sources */,
C49EC8362D501FB9005C3495 /* DataError.swift in Sources */,
2FE5DC2629EDD38A004B9AB4 /* Contacts.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -560,6 +583,7 @@
buildActionMask = 2147483647;
files = (
653A256228338800005D4D48 /* NeutroFeverGuardTests.swift in Sources */,
C49EC8382D5026EE005C3495 /* DataTypeTest.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
65 changes: 65 additions & 0 deletions NeutroFeverGuard/AddDataView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//
// This source file is part of the NeutroFeverGuard based on the Stanford Spezi Template Application project
//
// SPDX-FileCopyrightText: 2025 Stanford University
//
// SPDX-License-Identifier: MIT
//

import SwiftUI

struct DataTypeItem: Identifiable {
let id = UUID()
let name: String
}

struct AddDataView: View {
@State private var selectedDataType: DataTypeItem?

let dataTypes: [(name: String, emoji: String)] = [
(name: "Temperature", emoji: "🌡️"),
(name: "Heart Rate", emoji: "🫀"),
(name: "Oxygen Saturation", emoji: "🫁"),
(name: "Blood Pressure", emoji: "🩸"),
(name: "Lab Results", emoji: "🧪"),
(name: "Medication", emoji: "💊")
]

let columns = [GridItem(.flexible()), GridItem(.flexible())]

var body: some View {
VStack {
Text("What data would you like to add?")
.font(.title2)
.fontWeight(.bold)
.padding()

LazyVGrid(columns: columns, spacing: 20) {
ForEach(dataTypes, id: \.name) { item in
Button(action: {
self.selectedDataType = DataTypeItem(name: item.name)
}) {
VStack {
Text(item.emoji)
.font(.system(size: 40))
Text(item.name)
.font(.headline)
.foregroundColor(.primary)
}
.frame(width: 140, height: 100)
.background(Color(.systemGray6))
.cornerRadius(12)
}
}
}
.padding()
}
.sheet(item: $selectedDataType) { item in
DataInputForm(dataType: item.name)
}
}
}

#Preview {
AddDataView()
}
24 changes: 24 additions & 0 deletions NeutroFeverGuard/DataError.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// This source file is part of the NeutroFeverGuard based on the Stanford Spezi Template Application project
//
// SPDX-FileCopyrightText: 2025 Stanford University
//
// SPDX-License-Identifier: MIT
//

enum DataError: Error, Equatable {
case invalidDate
case invalidPercentage
case invalidBloodPressure

var errorMessage: String {
switch self {
case .invalidDate:
return "date can't be in future"
case .invalidPercentage:
return "percentage must be between 0 and 100"
case .invalidBloodPressure:
return "blood pressure must be greater than 0"
}
}
}
Loading
Loading