From 4a783a28219430be24fcf081ab8b5908d62e10e0 Mon Sep 17 00:00:00 2001 From: Vishnu Ravi Date: Sat, 4 Jan 2025 20:05:56 -0500 Subject: [PATCH] Move statistics to a new view --- LifeSpace.xcodeproj/project.pbxproj | 10 +++++--- LifeSpace/Account/AccountSheet.swift | 22 +++++++---------- LifeSpace/Account/StatisticsView.swift | 30 +++++++++++++++++++++++ LifeSpace/Resources/Localizable.xcstrings | 29 +++++++++++++++++++++- 4 files changed, 74 insertions(+), 17 deletions(-) create mode 100644 LifeSpace/Account/StatisticsView.swift diff --git a/LifeSpace.xcodeproj/project.pbxproj b/LifeSpace.xcodeproj/project.pbxproj index 0f0b0fd..72b64aa 100644 --- a/LifeSpace.xcodeproj/project.pbxproj +++ b/LifeSpace.xcodeproj/project.pbxproj @@ -73,6 +73,7 @@ 63BBF8192BB89CF7006890CE /* studyIDs.csv in Resources */ = {isa = PBXBuildFile; fileRef = 63BBF8182BB89CF7006890CE /* studyIDs.csv */; }; 63D86AD62C3B7F310096B9DB /* DocumentWebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63D86AD52C3B7F310096B9DB /* DocumentWebView.swift */; }; 63EA2CCA2D29C21800224C06 /* CompletedSurveysView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63EA2CC92D29C21800224C06 /* CompletedSurveysView.swift */; }; + 63EA2CCC2D2A0F4100224C06 /* StatisticsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63EA2CCB2D2A0F4100224C06 /* StatisticsView.swift */; }; 63EA5F7B2BC04F8400A48590 /* DailySurveyTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63EA5F7A2BC04F8400A48590 /* DailySurveyTask.swift */; }; 63EA5F892BC78ADD00A48590 /* DailySurveyTaskView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63EA5F882BC78ADD00A48590 /* DailySurveyTaskView.swift */; }; 63EA5F8C2BC78F8400A48590 /* DailySurveyResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63EA5F8B2BC78F8400A48590 /* DailySurveyResponse.swift */; }; @@ -164,6 +165,7 @@ 63CC66972C204CC5001DCFDF /* LifeSpace.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = LifeSpace.xctestplan; sourceTree = ""; }; 63D86AD52C3B7F310096B9DB /* DocumentWebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DocumentWebView.swift; sourceTree = ""; }; 63EA2CC92D29C21800224C06 /* CompletedSurveysView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompletedSurveysView.swift; sourceTree = ""; }; + 63EA2CCB2D2A0F4100224C06 /* StatisticsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatisticsView.swift; sourceTree = ""; }; 63EA5F7A2BC04F8400A48590 /* DailySurveyTask.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DailySurveyTask.swift; sourceTree = ""; }; 63EA5F882BC78ADD00A48590 /* DailySurveyTaskView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DailySurveyTaskView.swift; sourceTree = ""; }; 63EA5F8B2BC78F8400A48590 /* DailySurveyResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DailySurveyResponse.swift; sourceTree = ""; }; @@ -432,6 +434,7 @@ A9720E412ABB68B300872D23 /* Account */ = { isa = PBXGroup; children = ( + 63EA2CCB2D2A0F4100224C06 /* StatisticsView.swift */, 63EA2CC92D29C21800224C06 /* CompletedSurveysView.swift */, A9FE7ACF2AA39BAB0077B045 /* AccountSheet.swift */, A9720E422ABB68CC00872D23 /* AccountSetupHeader.swift */, @@ -716,6 +719,7 @@ 63BBF8162BB8993B006890CE /* StudyIDView.swift in Sources */, A9FE7AD02AA39BAB0077B045 /* AccountSheet.swift in Sources */, 653A2551283387FE005D4D48 /* LifeSpace.swift in Sources */, + 63EA2CCC2D2A0F4100224C06 /* StatisticsView.swift in Sources */, 2FE5DC3629EDD7CA004B9AB4 /* HealthKitPermissions.swift in Sources */, 2F65B44E2A3B8B0600A36932 /* NotificationPermissions.swift in Sources */, 27FA29902A388E9B009CAC45 /* ModalView.swift in Sources */, @@ -828,7 +832,7 @@ CODE_SIGN_ENTITLEMENTS = "LifeSpace/Supporting Files/LifeSpace.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 3; + CURRENT_PROJECT_VERSION = 4; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = ""; ENABLE_PREVIEWS = YES; @@ -1030,7 +1034,7 @@ CODE_SIGN_ENTITLEMENTS = "LifeSpace/Supporting Files/LifeSpace.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 3; + CURRENT_PROJECT_VERSION = 4; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = ""; ENABLE_PREVIEWS = YES; @@ -1078,7 +1082,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 3; + CURRENT_PROJECT_VERSION = 4; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = ""; diff --git a/LifeSpace/Account/AccountSheet.swift b/LifeSpace/Account/AccountSheet.swift index b2163cb..5e424d2 100644 --- a/LifeSpace/Account/AccountSheet.swift +++ b/LifeSpace/Account/AccountSheet.swift @@ -50,10 +50,6 @@ struct AccountSheet: View { @AppStorage(StorageKeys.studyID) var studyID = "unknownStudyID" @AppStorage(StorageKeys.trackingPreference) private var trackingOn = true - @AppStorage(StorageKeys.lastSurveyTransmissionDate) private var lastSurveyTransmissionDate = "None" - @AppStorage(StorageKeys.lastLocationTransmissionDate) private var lastLocationTransmissionDate = "None" - @AppStorage(StorageKeys.lastHealthKitTransmissionDate) private var lastHealthKitTransmissionDate = "None" - var body: some View { NavigationStack { ZStack { @@ -116,15 +112,7 @@ struct AccountSheet: View { if FeatureFlags.showDebugOptions { Section(header: Text("DEBUG_SECTION")) { logExportButton - } - Section(header: Text("LAST_SURVEY_TRANSMISSION_SECTION")) { - Text(lastSurveyTransmissionDate) - } - Section(header: Text("LAST_LOCATION_TRANSMISSION_SECTION")) { - Text(lastLocationTransmissionDate) - } - Section(header: Text("LAST_HEALTHKIT_TRANSMISSION_SECTION")) { - Text(lastHealthKitTransmissionDate) + statisticsButton } } } @@ -201,6 +189,14 @@ struct AccountSheet: View { } } + private var statisticsButton: some View { + NavigationLink(destination: { + StatisticsView() + }) { + Text("VIEW_STATISTICS") + } + } + private func getDocumentURL(for fileName: String) -> URL? { guard let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { return nil diff --git a/LifeSpace/Account/StatisticsView.swift b/LifeSpace/Account/StatisticsView.swift new file mode 100644 index 0000000..55aca71 --- /dev/null +++ b/LifeSpace/Account/StatisticsView.swift @@ -0,0 +1,30 @@ +// +// StatisticsView.swift +// LifeSpace +// +// Created by Vishnu Ravi on 1/4/25. +// + + +import SwiftUI + +struct StatisticsView: View { + @AppStorage(StorageKeys.lastSurveyTransmissionDate) private var lastSurveyTransmissionDate = "None" + @AppStorage(StorageKeys.lastLocationTransmissionDate) private var lastLocationTransmissionDate = "None" + @AppStorage(StorageKeys.lastHealthKitTransmissionDate) private var lastHealthKitTransmissionDate = "None" + + var body: some View { + Form { + Section(header: Text("LAST_SURVEY_TRANSMISSION_SECTION")) { + Text(lastSurveyTransmissionDate) + } + Section(header: Text("LAST_LOCATION_TRANSMISSION_SECTION")) { + Text(lastLocationTransmissionDate) + } + Section(header: Text("LAST_HEALTHKIT_TRANSMISSION_SECTION")) { + Text(lastHealthKitTransmissionDate) + } + } + .navigationTitle("STATISTICS_TITLE") + } +} diff --git a/LifeSpace/Resources/Localizable.xcstrings b/LifeSpace/Resources/Localizable.xcstrings index 4a995fb..c7b9b3d 100644 --- a/LifeSpace/Resources/Localizable.xcstrings +++ b/LifeSpace/Resources/Localizable.xcstrings @@ -536,7 +536,14 @@ } }, "LOGS_SHARE_PREVIEW_TITLE" : { - + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Share Logs" + } + } + } }, "NEXT_BUTTON" : { "localizations" : { @@ -749,6 +756,16 @@ } } }, + "STATISTICS_TITLE" : { + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Statistics" + } + } + } + }, "STUDYID_ACTION_BUTTON" : { "localizations" : { "en" : { @@ -989,6 +1006,16 @@ } } }, + "VIEW_STATISTICS" : { + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "View Statistics" + } + } + } + }, "Was Happy:" : { "localizations" : { "en" : {