From e9e0aa3ea2df3a6b43e428d6a757b25b82f9b85a Mon Sep 17 00:00:00 2001 From: Evelyn <122575337+evelyn-hur@users.noreply.github.com> Date: Mon, 4 Mar 2024 23:34:35 -0800 Subject: [PATCH] Fixed lint errors Fixed lint errors --- Prisma/PrivacyControls/DeleteDataView.swift | 8 ++ Prisma/PrivacyControls/ManageDataView.swift | 8 ++ Prisma/PrivacyControls/PrivacyModule.swift | 85 +++++-------------- .../Standard/PrismaStandard+HealthKit.swift | 11 ++- 4 files changed, 42 insertions(+), 70 deletions(-) diff --git a/Prisma/PrivacyControls/DeleteDataView.swift b/Prisma/PrivacyControls/DeleteDataView.swift index 8980434..c971d38 100644 --- a/Prisma/PrivacyControls/DeleteDataView.swift +++ b/Prisma/PrivacyControls/DeleteDataView.swift @@ -1,3 +1,11 @@ +// +// This source file is part of the Stanford Prisma Application based on the Stanford Spezi Template Application project +// +// SPDX-FileCopyrightText: 2023 Stanford University +// +// SPDX-License-Identifier: MIT +// + // // DeleteDataView.swift // Prisma diff --git a/Prisma/PrivacyControls/ManageDataView.swift b/Prisma/PrivacyControls/ManageDataView.swift index 1e50bd3..bdde07f 100644 --- a/Prisma/PrivacyControls/ManageDataView.swift +++ b/Prisma/PrivacyControls/ManageDataView.swift @@ -1,3 +1,11 @@ +// +// This source file is part of the Stanford Prisma Application based on the Stanford Spezi Template Application project +// +// SPDX-FileCopyrightText: 2023 Stanford University +// +// SPDX-License-Identifier: MIT +// + // // ManageDataView.swift // Prisma diff --git a/Prisma/PrivacyControls/PrivacyModule.swift b/Prisma/PrivacyControls/PrivacyModule.swift index 5889b05..4ad89d3 100644 --- a/Prisma/PrivacyControls/PrivacyModule.swift +++ b/Prisma/PrivacyControls/PrivacyModule.swift @@ -1,4 +1,12 @@ // +// This source file is part of the Stanford Prisma Application based on the Stanford Spezi Template Application project +// +// SPDX-FileCopyrightText: 2023 Stanford University +// +// SPDX-License-Identifier: MIT +// + + // PrivacyControls.swift // Prisma // @@ -16,8 +24,13 @@ import SwiftUI public class PrivacyModule: Module, EnvironmentAccessible { - public var iconsMapping: [String: String] = - [ + public struct DataCategoryItem { + var name: String + var iconName: String + var enabledStatus: String + } + + public var iconsMapping: [String: String] = [ "activeenergyburned": "flame", "distancewalkingrunning": "figure.walk", "heartrate": "waveform.path.ecg", @@ -52,21 +65,15 @@ public class PrivacyModule: Module, EnvironmentAccessible { "vo2max": "VO2 Max", "walkingheartrateaverage": "Walking Heart Rate Average" ] - - public struct DataCategoryItem { - var name: String - var iconName: String - var enabledStatus: String - } - var dataCategoryItems: [DataCategoryItem] = []; - + + var dataCategoryItems: [DataCategoryItem] = [] var sampleTypeList: [HKSampleType] @StandardActor var standard: PrismaStandard public required init(sampleTypeList: [HKSampleType]) { self.sampleTypeList = sampleTypeList - dataCategoryItems = self.getDataCategoryItems() + self.dataCategoryItems = self.getDataCategoryItems() } var configuration: Configuration { @@ -74,7 +81,6 @@ public class PrivacyModule: Module, EnvironmentAccessible { } public func getDataCategoryItems() -> [DataCategoryItem] { - var dataCategoryItems: [DataCategoryItem] = [] // make dictionary into alphabetically sorted array of key-value tuples let sortedDataCategoryItems = identifierUIString.sorted { $0.key < $1.key } for dataCategoryPair in sortedDataCategoryItems { @@ -89,66 +95,13 @@ public class PrivacyModule: Module, EnvironmentAccessible { return dataCategoryItems } - public func getHKSampleTypeMappings() async{ + public func getHKSampleTypeMappings() async { var toggleMapUpdated: [String: Bool] = [:] for sampleType in sampleTypeList { let identifier = await standard.getSampleIdentifierFromHKSampleType(sampleType: sampleType) toggleMapUpdated[identifier ?? "Unidentified Sample Type"] = true } - } - - // var sampleToToggleNameMapping: [String: Bool] = [ - // getSampleIdentifier(HKSample): true, - // HKQuantityType.quantityType(forIdentifier: .stepCount): "includeStepCountUpload", - // HKQuantityType.quantityType(forIdentifier: .distanceWalkingRunning): "includeDistanceWalkingRunning", - // HKQuantityType.quantityType(forIdentifier: .vo2Max): "includeVo2Max", - // HKQuantityType.quantityType(forIdentifier: .heartRate): "includeHeartRate", - // HKQuantityType.quantityType(forIdentifier: .restingHeartRate): "includeRestingHeartRate", - // HKQuantityType.quantityType(forIdentifier: .oxygenSaturation): "includeOxygenSaturation", - // HKQuantityType.quantityType(forIdentifier: .respiratoryRate): "includeRespiratoryRate", - // HKQuantityType.quantityType(forIdentifier: .walkingHeartRateAverage): "includeWalkingHeartRateAverage" - // ] - - - // public func getCurrentToggles() -> [String: Bool] { - // [ - // "includeStepCountUpload": includeStepCountUpload, - // "includeActiveEnergyBurned": includeActiveEnergyBurned, - // "includeDistanceWalkingRunning": includeDistanceWalkingRunning, - // "includeVo2Max": includeVo2Max, - // "includeHeartRate": includeHeartRate, - // "includeRestingHeartRate": includeRestingHeartRate, - // "includeOxygenSaturation": includeOxygenSaturation, - // "includeRespiratoryRate": includeRespiratoryRate, - // "includeWalkingHRAverage": includeWalkingHRAverage - // ] - // } - // public func getLastTimestamps(quantityType: String) async -> [String] { - // var path: String = "" - // - // do { - // path = try await standard.getPath(module: .health(quantityType)) + "raw/" - // } catch { - // print("Error retrieving user document: \(error)") - // } - // - // var lastTimestampsArr: [String] = [] - // - // do { - // let querySnapshot = try await Firestore.firestore().collection(path).getDocuments() - // for document in querySnapshot.documents { - // lastTimestampsArr.append(document.documentID) - //// print("\(document.documentID) => \(document.data())") - // } - // } catch { - // print("Error getting documents: \(error)") - // } - // - // return lastTimestampsArr - // } - - } diff --git a/Prisma/Standard/PrismaStandard+HealthKit.swift b/Prisma/Standard/PrismaStandard+HealthKit.swift index ce2e3c8..31b8c7f 100644 --- a/Prisma/Standard/PrismaStandard+HealthKit.swift +++ b/Prisma/Standard/PrismaStandard+HealthKit.swift @@ -47,14 +47,17 @@ extension PrismaStandard { } } + /// Takes in HKSampleType and returns the corresponding identifier string + /// + /// - Parameters: + /// - sampleType: HKSampleType to find identifier for + /// - Returns: A string for the sample type identifier. public func getSampleIdentifierFromHKSampleType(sampleType: HKSampleType) -> String? { if let quantityType = sampleType as? HKQuantityType { return quantityType.identifier - } - else if let categoryType = sampleType as? HKCategoryType { + } else if let categoryType = sampleType as? HKCategoryType { return categoryType.identifier - } - else if sampleType is HKWorkoutType { + } else if sampleType is HKWorkoutType { return "workout" } // Default case for other HKSampleTypes